Skip to content

Commit 5a2eddb

Browse files
committed
Generate the bci-base container via dockerfile generator as well
1 parent d003857 commit 5a2eddb

6 files changed

Lines changed: 204 additions & 104 deletions

File tree

src/bci_build/package/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,9 @@ def pkg_filter_func(p: str | Package) -> bool:
971971

972972
return pkg_filter_func
973973

974+
def pkg_listing_func(pkg: Package) -> str:
975+
return f'<package name="{pkg}"/>'
976+
974977
PKG_TYPES = (
975978
PackageType.DELETE,
976979
PackageType.BOOTSTRAP,
@@ -991,8 +994,7 @@ def pkg_filter_func(p: str | Package) -> bool:
991994
res += (
992995
f""" <packages type="{pkg_type}">
993996
"""
994-
+ """
995-
""".join(f'<package name="{pkg}"/>' for pkg in pkg_list)
997+
+ "\n ".join(pkg_listing_func(pkg) for pkg in pkg_list)
996998
+ """
997999
</packages>
9981000
"""
@@ -1552,7 +1554,7 @@ def generate_disk_size_constraints(size_gb: int) -> str:
15521554
from .appcontainers import THREE_EIGHT_NINE_DS_CONTAINERS # noqa: E402
15531555
from .appcontainers import TOMCAT_CONTAINERS # noqa: E402
15541556
from .appcontainers import TRIVY_CONTAINERS # noqa: E402
1555-
from .basalt_base import BASALT_BASE # noqa: E402
1557+
from .base import BASE_CONTAINERS # noqa: E402
15561558
from .basecontainers import BUSYBOX_CONTAINERS # noqa: E402
15571559
from .basecontainers import FIPS_BASE_CONTAINERS # noqa: E402
15581560
from .basecontainers import GITEA_RUNNER_CONTAINER # noqa: E402
@@ -1579,7 +1581,7 @@ def generate_disk_size_constraints(size_gb: int) -> str:
15791581
ALL_CONTAINER_IMAGE_NAMES: dict[str, BaseContainerImage] = {
15801582
f"{bci.uid}-{bci.os_version.pretty_print.lower()}": bci
15811583
for bci in (
1582-
BASALT_BASE,
1584+
*BASE_CONTAINERS,
15831585
PYTHON_3_12_CONTAINERS,
15841586
*PYTHON_3_6_CONTAINERS,
15851587
*PYTHON_3_11_CONTAINERS,

src/bci_build/package/basalt_base.py

Lines changed: 0 additions & 99 deletions
This file was deleted.

src/bci_build/package/base.py

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
""" The base container image is the base image with zypper included."""
2+
3+
import textwrap
4+
5+
from bci_build.package import ALL_BASE_OS_VERSIONS
6+
from bci_build.package import OsVersion
7+
from bci_build.package import OsContainer
8+
from bci_build.package import BuildType
9+
from bci_build.package import SupportLevel
10+
from bci_build.package import Package
11+
from bci_build.package import PackageType
12+
from bci_build.package import CAN_BE_LATEST_OS_VERSION
13+
14+
def _get_base_config_sh_script(os_version: OsVersion) -> str:
15+
return textwrap.dedent(
16+
r"""
17+
echo "Configure image: [$kiwi_iname]..."
18+
19+
#======================================
20+
# Setup baseproduct link
21+
#--------------------------------------
22+
suseSetupProduct
23+
24+
#======================================
25+
# Import repositories' keys
26+
#--------------------------------------
27+
suseImportBuildKey
28+
29+
30+
# don't have duplicate licenses of the same type
31+
jdupes -1 -L -r /usr/share/licenses
32+
33+
zypper --non-interactive rm -u jdupes
34+
35+
# Not needed, but neither rpm nor libzypp handle rpmlib(X-CheckUnifiedSystemdir) yet
36+
# which would avoid it being installed by filesystem package
37+
rpm -e compat-usrmerge-tools
38+
39+
#======================================
40+
# Disable recommends
41+
#--------------------------------------
42+
sed -i 's/.*solver.onlyRequires.*/solver.onlyRequires = true/g' /etc/zypp/zypp.conf
43+
44+
#======================================
45+
# Exclude docs installation
46+
#--------------------------------------
47+
sed -i 's/.*rpm.install.excludedocs.*/rpm.install.excludedocs = yes/g' /etc/zypp/zypp.conf
48+
49+
#======================================
50+
# Configure SLE BCI repositories
51+
#--------------------------------------
52+
zypper -n ar --refresh --gpgcheck --priority 100 --enable 'https://updates.suse.com/SUSE/Products/SLE-BCI/$releasever_major-SP$releasever_minor/$basearch/product/' SLE_BCI
53+
zypper -n ar --refresh --gpgcheck --priority 100 --disable 'https://updates.suse.com/SUSE/Products/SLE-BCI/$releasever_major-SP$releasever_minor/$basearch/product_debug/' SLE_BCI_debug
54+
zypper -n ar --refresh --gpgcheck --priority 100 --disable 'https://updates.suse.com/SUSE/Products/SLE-BCI/$releasever_major-SP$releasever_minor/$basearch/product_source/' SLE_BCI_source
55+
56+
#======================================
57+
# Remove locale files
58+
#--------------------------------------
59+
shopt -s globstar
60+
rm -f /usr/share/locale/**/*.mo
61+
62+
#======================================
63+
# Remove zypp uuid (bsc#1098535)
64+
#--------------------------------------
65+
rm -f /var/lib/zypp/AnonymousUniqueId
66+
67+
# Remove various log files. Although possible to just rm -rf /var/log/*, that
68+
# would also remove some package owned directories (not %ghost) and some files
69+
# are actually wanted, like lastlog in the !docker case.
70+
# For those wondering about YaST2 here: Kiwi writes /etc/hosts, so the version
71+
# from the netcfg package ends up as /etc/hosts.rpmnew, which zypper writes a
72+
# letter about to /var/log/YaST2/config_diff_2022_03_06.log. Kiwi fixes this,
73+
# but the log file remains.
74+
rm -rf /var/log/{zypper.log,zypp/history,YaST2}
75+
76+
# Remove the entire zypper cache content (not the dir itself, owned by libzypp)
77+
rm -rf /var/cache/zypp/*
78+
79+
#==========================================
80+
# Hack! The go container management tools can't handle sparse files:
81+
# https://github.com/golang/go/issues/13548
82+
# If lastlog doesn't exist, useradd doesn't attempt to reserve space,
83+
# also in derived containers.
84+
#------------------------------------------
85+
rm -f /var/log/lastlog
86+
87+
#======================================
88+
# Remove locale files
89+
#--------------------------------------
90+
find /usr/share/locale -name '*.mo' -delete
91+
92+
exit 0
93+
"""
94+
)
95+
96+
97+
BASE_CONTAINERS = [
98+
OsContainer(
99+
name="base",
100+
pretty_name="Base Container Image",
101+
package_name="sles15-image" if os_ver.is_sle15 else "base-image",
102+
logo_url="https://opensource.suse.com/bci/SLE_BCI_logomark_green.svg",
103+
build_recipe_type=BuildType.KIWI,
104+
from_image=None,
105+
os_version=os_ver,
106+
support_level=SupportLevel.L3,
107+
is_latest=os_ver in CAN_BE_LATEST_OS_VERSION,
108+
package_list=[
109+
Package(name=pkg_name, pkg_type=PackageType.IMAGE)
110+
for pkg_name in (
111+
"bash",
112+
"ca-certificates-mozilla",
113+
"ca-certificates",
114+
"container-suseconnect",
115+
"coreutils",
116+
"curl",
117+
"findutils",
118+
"glibc-locale-base",
119+
"gzip",
120+
"lsb-release",
121+
"netcfg",
122+
"openssl",
123+
"skelcd-EULA-bci",
124+
"sle-module-basesystem-release",
125+
"sle-module-server-applications-release",
126+
"sle-module-python3-release",
127+
"suse-build-key",
128+
"tar",
129+
"timezone",
130+
)
131+
]
132+
+ [
133+
Package(name=pkg_name, pkg_type=PackageType.BOOTSTRAP)
134+
for pkg_name in (
135+
"aaa_base",
136+
"cracklib-dict-small",
137+
"filesystem",
138+
"jdupes",
139+
"kubic-locale-archive",
140+
"patterns-base-fips",
141+
"patterns-base-minimal_base",
142+
"rpm-ndb",
143+
"shadow",
144+
"sles-release",
145+
"zypper",
146+
)
147+
],
148+
config_sh_script=_get_base_config_sh_script(os_ver),
149+
)
150+
for os_ver in ALL_BASE_OS_VERSIONS
151+
]

src/bci_build/package/base/LICENSE

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Permission is hereby granted, free of charge, to any person obtaining a copy
2+
of this software and associated documentation files (the "Software"), to deal
3+
in the Software without restriction, including without limitation the rights
4+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5+
copies of the Software, and to permit persons to whom the Software is
6+
furnished to do so, subject to the following conditions:
7+
8+
The above copyright notice and this permission notice shall be included in
9+
all copies or substantial portions of the Software.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17+
SOFTWARE.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# {{ image.title }}
2+
{% include 'badges.j2' %}
3+
4+
## Description
5+
6+
SUSE Linux Enterprise Base Container Images (SLE BCI) provide truly open,
7+
flexible, and secure container images and application development tools. The
8+
images consist of container environments based on SUSE Linux Enterprise and
9+
designed to be a secure base for any containerized workload.
10+
11+
SLE BCI is freely available, re-distributable, and supported across many
12+
different environments. These templates and tools address modern, containerized
13+
application development and CI/CD application containerization. They can be
14+
used immediately by developers and integrators without the “lock-in” imposed by
15+
other offerings.
16+
17+
SLE BCI inherits industry-leading security and compliance from SUSE Linux
18+
within your container build process. The container images are designed to be a
19+
secure base for any application workload. SUSE ensures that compliance
20+
standards are applied consistently and continuously improves security-related
21+
capabilities.
22+
23+
SLE BCI is lightweight and easy to adopt, with the ability to run with any
24+
Linux OS. Avoid lock-in imposed by other vendors and get exactly what you need,
25+
fast. SLE BCI delivers a flexible developer experience that accounts for,
26+
integrates with, and supports language-native tools and workflows.
27+
28+
## Usage
29+
30+
{% include 'licensing_and_eula.j2' %}

src/bci_build/package/basecontainers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
_DISABLE_GETTY_AT_TTY1_SERVICE = "systemctl disable getty@tty1.service"
2424

25-
2625
MICRO_CONTAINERS = [
2726
OsContainer(
2827
name="micro",

0 commit comments

Comments
 (0)