Skip to content

Commit

Permalink
Adjust containers recipes to SLCC_* split
Browse files Browse the repository at this point in the history
  • Loading branch information
dcermak committed Apr 23, 2024
1 parent d76ec45 commit dd3e9e7
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 82 deletions.
6 changes: 3 additions & 3 deletions src/bci_build/package/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1462,13 +1462,13 @@ def generate_disk_size_constraints(size_gb: int) -> str:
from .python import PYTHON_TW_CONTAINERS # noqa: E402
from .ruby import RUBY_CONTAINERS # noqa: E402
from .rust import RUST_CONTAINERS # noqa: E402
from .slcc_base import SLCC_BASE # noqa: E402
from .slcc_base import SLCC_BASE_CONTAINERS # noqa: E402

ALL_CONTAINER_IMAGE_NAMES: Dict[str, BaseContainerImage] = {
f"{bci.uid}-{bci.os_version.pretty_print.lower()}": bci
for bci in (
SLCC_BASE,
PYTHON_3_12_CONTAINERS,
*SLCC_BASE_CONTAINERS,
*PYTHON_3_12_CONTAINERS,
*PYTHON_3_6_CONTAINERS,
*PYTHON_3_11_CONTAINERS,
*PYTHON_TW_CONTAINERS,
Expand Down
41 changes: 26 additions & 15 deletions src/bci_build/package/appcontainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
pretty_name="Performance Co-Pilot (pcp)",
custom_description="{pretty_name} container {based_on_container}. {podman_only}",
package_name="pcp-image",
from_image=f"{_build_tag_prefix(os_version)}/bci-init:{OsContainer.version_to_container_os_version(os_version)}",
from_image=f"{_build_tag_prefix(os_version)}/{OsContainer.build_tag_name_prefix(os_version)}init:{OsContainer.version_to_container_os_version(os_version)}",
os_version=os_version,
is_latest=os_version in CAN_BE_LATEST_OS_VERSION,
support_level=SupportLevel.L3,
Expand Down Expand Up @@ -149,13 +149,13 @@
MARIADB_CONTAINERS = []
MARIADB_CLIENT_CONTAINERS = []

for os_version in set(ALL_NONBASE_OS_VERSIONS) | {OsVersion.SLCC}:
if os_version in (OsVersion.SLCC, OsVersion.TUMBLEWEED):
prefix = ""
additional_names = []
else:
for os_version in ALL_NONBASE_OS_VERSIONS:
if os_version.is_sles:
prefix = "rmt-"
additional_names = ["mariadb"]
else:
prefix = ""
additional_names = []

MARIADB_CONTAINERS.append(
ApplicationStackContainer(
Expand Down Expand Up @@ -326,11 +326,20 @@
""",
)
for ver, os_version in (
[(15, variant) for variant in (OsVersion.SP5, OsVersion.TUMBLEWEED)]
[
(15, variant)
for variant in (
OsVersion.SP5,
OsVersion.TUMBLEWEED,
OsVersion.SLCC_PRODUCTION,
OsVersion.SLCC_DEVELOPMENT,
)
]
+ [
(16, variant)
for variant in (
OsVersion.SLCC,
OsVersion.SLCC_DEVELOPMENT,
OsVersion.SLCC_PRODUCTION,
OsVersion.SP5,
OsVersion.SP6,
OsVersion.TUMBLEWEED,
Expand Down Expand Up @@ -512,7 +521,9 @@ def _get_nginx_kwargs(os_version: OsVersion):
pretty_name="NGINX for SUSE RMT",
**_get_nginx_kwargs(os_version),
)
for os_version in ALL_NONBASE_OS_VERSIONS
for os_version in set(ALL_NONBASE_OS_VERSIONS).difference(
{OsVersion.SLCC_PRODUCTION, OsVersion.TUMBLEWEED}
)
] + [
ApplicationStackContainer(
name="nginx",
Expand All @@ -532,7 +543,7 @@ def _get_nginx_kwargs(os_version: OsVersion):
package_name="git-image",
pretty_name=f"{os_version.pretty_os_version_no_dash} with Git",
custom_description="A micro environment with Git {based_on_container}.",
from_image=f"{_build_tag_prefix(os_version)}/bci-micro:{OsContainer.version_to_container_os_version(os_version)}",
from_image=f"{_build_tag_prefix(os_version)}/{OsContainer.build_tag_name_prefix(os_version)}micro:{OsContainer.version_to_container_os_version(os_version)}",
build_recipe_type=BuildType.KIWI,
is_latest=os_version in CAN_BE_LATEST_OS_VERSION,
version="%%git_version%%",
Expand All @@ -551,7 +562,7 @@ def _get_nginx_kwargs(os_version: OsVersion):
"git-core",
"openssh-clients",
)
+ (() if os_version == OsVersion.TUMBLEWEED else ("skelcd-EULA-bci",))
+ os_version.eula_package_names
],
# intentionally empty
config_sh_script="""
Expand All @@ -566,7 +577,7 @@ def _get_nginx_kwargs(os_version: OsVersion):
name="registry",
pretty_name="OCI Container Registry (Distribution)",
package_name="distribution-image",
from_image=f"{_build_tag_prefix(os_version)}/bci-micro:{OsContainer.version_to_container_os_version(os_version)}",
from_image=f"{_build_tag_prefix(os_version)}/{OsContainer.build_tag_name_prefix(os_version)}micro:{OsContainer.version_to_container_os_version(os_version)}",
os_version=os_version,
is_latest=os_version in CAN_BE_LATEST_OS_VERSION,
version="%%registry_version%%",
Expand Down Expand Up @@ -606,7 +617,7 @@ def _get_nginx_kwargs(os_version: OsVersion):
name="helm",
pretty_name="Kubernetes Package Manager",
package_name="helm-image",
from_image=f"{_build_tag_prefix(os_version)}/bci-micro:{OsContainer.version_to_container_os_version(os_version)}",
from_image=f"{_build_tag_prefix(os_version)}/{OsContainer.build_tag_name_prefix(os_version)}micro:{OsContainer.version_to_container_os_version(os_version)}",
os_version=os_version,
is_latest=os_version in CAN_BE_LATEST_OS_VERSION,
version="%%helm_version%%",
Expand Down Expand Up @@ -640,7 +651,7 @@ def _get_nginx_kwargs(os_version: OsVersion):
name="trivy",
pretty_name="Container Vulnerability Scanner",
package_name="trivy-image",
from_image=f"{_build_tag_prefix(os_version)}/bci-micro:{OsContainer.version_to_container_os_version(os_version)}",
from_image=f"{_build_tag_prefix(os_version)}/{OsContainer.build_tag_name_prefix(os_version)}micro:{OsContainer.version_to_container_os_version(os_version)}",
os_version=os_version,
is_latest=os_version in CAN_BE_LATEST_OS_VERSION,
version="%%trivy_version%%",
Expand Down Expand Up @@ -701,7 +712,7 @@ def _get_nginx_kwargs(os_version: OsVersion):
),
],
cmd=[
f"/usr/{'libexec' if os_version in( OsVersion.TUMBLEWEED, OsVersion.SLCC) else 'lib'}/tomcat/server",
f"/usr/{'lib' if os_version.is_sles else 'libexec'}/tomcat/server",
"start",
],
exposes_tcp=[8080],
Expand Down
23 changes: 11 additions & 12 deletions src/bci_build/package/basecontainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@
def _get_os_container_package_names(os_version: OsVersion) -> tuple[str, ...]:
if os_version == OsVersion.TUMBLEWEED:
return ("openSUSE-release", "openSUSE-release-appliance-docker")
if os_version == OsVersion.SLCC:
if os_version in (OsVersion.SLCC_DEVELOPMENT, OsVersion.SLCC_PRODUCTION):
return ("SL-Micro-release",)
if os_version == OsVersion.SLCC_LTS:
# FIXME: wrong, but we don't have SLES 16 yet
return ("ALP-dummy-release",)
return ("sles-release",)


def _get_eula_package_names(os_version: OsVersion) -> tuple[str, ...]:
if os_version in (OsVersion.TUMBLEWEED, OsVersion.SLCC):
return ()
return ("skelcd-EULA-bci",)


MICRO_CONTAINERS = [
OsContainer(
name="micro",
Expand All @@ -55,7 +52,7 @@ def _get_eula_package_names(os_version: OsVersion) -> tuple[str, ...]:
# ca-certificates-mozilla-prebuilt requires /bin/cp, which is otherwise not resolved…
"coreutils",
)
+ _get_eula_package_names(os_version)
+ os_version.eula_package_names
+ _get_os_container_package_names(os_version)
],
# intentionally empty
Expand Down Expand Up @@ -152,7 +149,7 @@ def _get_minimal_kwargs(os_version: OsVersion):
Package(name, pkg_type=PackageType.BOOTSTRAP)
for name in _get_os_container_package_names(os_version)
]
if os_version in (OsVersion.TUMBLEWEED, OsVersion.SLCC):
if os_version in (OsVersion.TUMBLEWEED, OsVersion.SLCC_PRODUCTION):
package_list.append(Package("rpm", pkg_type=PackageType.BOOTSTRAP))
else:
# in SLE15, rpm still depends on Perl.
Expand All @@ -161,8 +158,10 @@ def _get_minimal_kwargs(os_version: OsVersion):
for name in ("rpm-ndb", "perl-base")
]

micro_name = "micro" if os_version.is_slcc else "bci-micro"

kwargs = {
"from_image": f"{_build_tag_prefix(os_version)}/bci-micro:{OsContainer.version_to_container_os_version(os_version)}",
"from_image": f"{_build_tag_prefix(os_version)}/{micro_name}:{OsContainer.version_to_container_os_version(os_version)}",
"pretty_name": f"{os_version.pretty_os_version_no_dash} Minimal",
"package_list": package_list,
}
Expand Down Expand Up @@ -214,7 +213,7 @@ def _get_minimal_kwargs(os_version: OsVersion):
"busybox-links",
"ca-certificates-mozilla-prebuilt",
)
+ _get_eula_package_names(os_version)
+ os_version.eula_package_names
],
config_sh_script=textwrap.dedent(
"""
Expand All @@ -232,7 +231,7 @@ def _get_minimal_kwargs(os_version: OsVersion):
KERNEL_MODULE_CONTAINERS = []

for os_version in ALL_OS_VERSIONS - {OsVersion.TUMBLEWEED}:
if os_version == OsVersion.SLCC:
if os_version.is_slcc:
prefix = "slci"
pretty_prefix = prefix.upper()
else:
Expand Down
15 changes: 12 additions & 3 deletions src/bci_build/package/golang.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,25 @@ def _get_golang_kwargs(
support_level=SupportLevel.L3,
)
for ver, govariant, sle15sp in product(
_GOLANG_VERSIONS, ("",), (OsVersion.SP5, OsVersion.SP6)
_GOLANG_VERSIONS,
("",),
(OsVersion.SP5, OsVersion.SP6, OsVersion.SLCC_PRODUCTION),
)
]
+ [
LanguageStackContainer(
**_get_golang_kwargs(ver, govariant, sle15sp),
support_level=SupportLevel.L3,
)
for ver, govariant, sle15sp in product(
_GOLANG_OPENSSL_VERSIONS, ("-openssl",), (OsVersion.SP5, OsVersion.SP6)
for ver, govariant, sle15sp in (
list(
product(
_GOLANG_OPENSSL_VERSIONS,
("-openssl",),
(OsVersion.SP5, OsVersion.SP6),
)
)
+ [("1.21", "-openssl", OsVersion.SLCC_PRODUCTION)]
)
]
+ [
Expand Down
3 changes: 2 additions & 1 deletion src/bci_build/package/openjdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def _get_openjdk_kwargs(
support_level=SupportLevel.L3,
)
for os_version, devel in product(
(OsVersion.SP6, OsVersion.TUMBLEWEED), (True, False)
(OsVersion.SP6, OsVersion.SLCC_PRODUCTION, OsVersion.TUMBLEWEED),
(True, False),
)
]
)
37 changes: 26 additions & 11 deletions src/bci_build/package/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ def _get_python_kwargs(
if os_version == OsVersion.TUMBLEWEED:
has_pipx = True
# Enabled only for Python 3.11 on SLE15 (jsc#PED-5573)
if os_version not in (OsVersion.SLCC, OsVersion.TUMBLEWEED) and py3_ver == "3.11":
if (
os_version not in (OsVersion.SLCC_PRODUCTION, OsVersion.TUMBLEWEED)
and py3_ver == "3.11"
):
has_pipx = True

kwargs = {
Expand Down Expand Up @@ -87,7 +90,7 @@ def _get_python_kwargs(
PYTHON_TW_CONTAINERS = (
LanguageStackContainer(
**_get_python_kwargs(pyver, OsVersion.TUMBLEWEED),
is_latest=pyver == _PYTHON_TW_VERSIONS[-1],
is_latest=(pyver == _PYTHON_TW_VERSIONS[-1]),
package_name=f"python-{pyver}-image",
)
for pyver in _PYTHON_TW_VERSIONS
Expand All @@ -100,16 +103,28 @@ def _get_python_kwargs(
support_level=SupportLevel.L3,
# https://peps.python.org/pep-0664/ defines 2027/10/31, SUSE offers until end of the year
supported_until=datetime.date(2027, 12, 31),
is_latest=os_version in CAN_BE_LATEST_OS_VERSION,
is_latest=(
(os_version in CAN_BE_LATEST_OS_VERSION)
and (os_version != OsVersion.SLCC_PRODUCTION)
),
)
for os_version in (OsVersion.SP5, OsVersion.SP6)
for os_version in (OsVersion.SP5, OsVersion.SP6, OsVersion.SLCC_PRODUCTION)
)

PYTHON_3_12_CONTAINERS = LanguageStackContainer(
**_get_python_kwargs("3.12", OsVersion.SP6),
package_name="python-3.12-image",
support_level=SupportLevel.L3,
supported_until=_SUPPORTED_UNTIL_SLE[OsVersion.SP6],
# Technically it is the latest but we want to prefer the long term Python 3.11
is_latest=False,
PYTHON_3_12_CONTAINERS = (
LanguageStackContainer(
**_get_python_kwargs("3.12", os_version),
package_name="python-3.12-image",
support_level=SupportLevel.L3,
# we provide support until for 3.12 on SLES 15 SP6 until the support end
# of that and for SLCC for half its upstream bugfix lifecycle
supported_until=(
_SUPPORTED_UNTIL_SLE[OsVersion.SP6]
if os_version == OsVersion.SP6
else datetime.date(2025, 5, 31)
),
# Technically it is the latest but we want to prefer the long term Python 3.11
is_latest=os_version == OsVersion.SLCC_PRODUCTION,
)
for os_version in (OsVersion.SP6, OsVersion.SLCC_PRODUCTION)
)
77 changes: 40 additions & 37 deletions src/bci_build/package/slcc_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,43 @@
from bci_build.package import Package
from bci_build.package import PackageType

SLCC_BASE = OsContainer(
name="base",
pretty_name="Base",
package_name="base-image",
build_recipe_type=BuildType.KIWI,
from_image=None,
os_version=OsVersion.SLCC,
is_latest=True,
package_list=[
Package(name=pkg_name, pkg_type=PackageType.BOOTSTRAP)
for pkg_name in (
"aaa_base",
"bash",
"ca-certificates",
"ca-certificates-mozilla",
"coreutils",
"cracklib-dict-small",
"curl",
"filesystem",
"glibc-locale-base",
"gzip",
"jdupes",
"netcfg",
# FIXME: enable this once it's on OBS
# "lsb-release",
"ALP-dummy-release",
"openssl",
"suse-build-key",
# "patterns-alp-base",
"tar",
"timezone",
"zypper",
"findutils",
)
],
config_sh_script=r"""echo "Configure image: [$kiwi_iname]..."
SLCC_BASE_CONTAINERS = [
OsContainer(
name="base",
pretty_name="Base",
package_name="base-image",
build_recipe_type=BuildType.KIWI,
from_image=None,
os_version=os_version,
is_latest=True,
package_list=[
Package(name=pkg_name, pkg_type=PackageType.BOOTSTRAP)
for pkg_name in (
"aaa_base",
"bash",
"ca-certificates",
"ca-certificates-mozilla",
"coreutils",
"cracklib-dict-small",
"curl",
"filesystem",
"glibc-locale-base",
"gzip",
"jdupes",
"netcfg",
# FIXME: enable this once it's on OBS
# "lsb-release",
"SL-Micro-release",
"openssl",
"suse-build-key",
# "patterns-alp-base",
"tar",
"timezone",
"zypper",
"findutils",
)
],
config_sh_script=r"""echo "Configure image: [$kiwi_iname]..."
# don't have multiple licenses of the same type
jdupes -1 -L -r /usr/share/licenses
Expand Down Expand Up @@ -96,4 +97,6 @@
grep -q '^arch =' /etc/zypp/zypp.conf
fi
""",
)
)
for os_version in (OsVersion.SLCC_DEVELOPMENT, OsVersion.SLCC_PRODUCTION)
]

0 comments on commit dd3e9e7

Please sign in to comment.