Skip to content

Commit

Permalink
Remove util-linux from the tomcat containers
Browse files Browse the repository at this point in the history
This is only needed for the runuser command in the post script
and not needed in the final container.
  • Loading branch information
dirkmueller committed Sep 25, 2024
1 parent 73ab954 commit d223369
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 7 deletions.
21 changes: 19 additions & 2 deletions src/bci_build/package/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,12 +864,29 @@ def packages(self) -> str:
:command:`zypper in`.
"""
packages_to_install: list[str] = []
for pkg in self.package_list:
if isinstance(pkg, Package) and pkg.pkg_type != PackageType.IMAGE:
if isinstance(pkg, Package) and pkg.pkg_type not in (
PackageType.IMAGE,
PackageType.DELETE,
):
raise ValueError(
f"Cannot add a package of type {pkg.pkg_type} into a Dockerfile based build."
)
return " ".join(str(pkg) for pkg in self.package_list)
if isinstance(pkg, Package) and pkg.pkg_type == PackageType.DELETE:
continue
packages_to_install.append(str(pkg))
return " ".join(packages_to_install)

@property
def packages_to_delete(self) -> str:
"""The list of packages joined that can be passed to zypper -n rm after an install`."""
packages_to_delete: list[str] = [
str(pkg)
for pkg in self.package_list
if (isinstance(pkg, Package) and pkg.pkg_type == PackageType.DELETE)
]
return " ".join(packages_to_delete)

@overload
def _kiwi_volumes_expose(
Expand Down
3 changes: 3 additions & 0 deletions src/bci_build/package/apache_tomcat.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from bci_build.package import DOCKERFILE_RUN
from bci_build.package import OsContainer
from bci_build.package import OsVersion
from bci_build.package import Package
from bci_build.package import PackageType
from bci_build.package import Replacement
from bci_build.package import _build_tag_prefix

Expand Down Expand Up @@ -82,6 +84,7 @@ def _get_sac_supported_until(
"curl",
# currently needed by custom_end
"sed",
Package("util-linux", PackageType.DELETE),
]
+ [f"java-{jre_version}-openjdk", f"java-{jre_version}-openjdk-headless"],
replacements_via_service=[
Expand Down
9 changes: 8 additions & 1 deletion src/bci_build/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@
COPY --from=target / /target
{%- endif %}
{% if image.packages %}{{ DOCKERFILE_RUN }} zypper{% if image.from_target_image %} --installroot /target --gpg-auto-import-keys {% endif %} -n in {% if image.no_recommends %}--no-recommends {% endif %}{{ image.packages }}; zypper -n clean; {{ LOG_CLEAN }}{% endif %}
{% if image.packages %}{{ DOCKERFILE_RUN }} \\
zypper -n {%- if image.from_target_image %} --installroot /target --gpg-auto-import-keys {%- endif %} install {% if image.no_recommends %}--no-recommends {% endif %}{{ image.packages }}; \\
{%- if image.packages_to_delete %}
zypper -n {%- if image.from_target_image %} --installroot /target {%- endif %} remove {{ image.packages_to_delete }}; \\
{%- endif %}
zypper -n clean; \\
{{ LOG_CLEAN }}
{%- endif %}
{% if image.from_target_image %}FROM {{ image.dockerfile_from_target_ref }}
COPY --from=builder /target /{% endif %}
# Define labels according to https://en.opensuse.org/Building_derived_containers
Expand Down
20 changes: 16 additions & 4 deletions tests/test_build_recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
#!BuildVersion: 15.6.27
FROM bci/bci-base:15.6
RUN zypper -n in --no-recommends gcc emacs; zypper -n clean; ##LOGCLEAN##
RUN \\
zypper -n install --no-recommends gcc emacs; \\
zypper -n clean; \\
##LOGCLEAN##
# Define labels according to https://en.opensuse.org/Building_derived_containers
# labelprefix=com.suse.bci.test
Expand Down Expand Up @@ -140,7 +143,10 @@
#!BuildVersion: 15.5
FROM bci/bci-base:15.5
RUN zypper -n in --no-recommends gcc emacs; zypper -n clean; ##LOGCLEAN##
RUN \\
zypper -n install --no-recommends gcc emacs; \\
zypper -n clean; \\
##LOGCLEAN##
# Define labels according to https://en.opensuse.org/Building_derived_containers
# labelprefix=com.suse.bci.test
Expand Down Expand Up @@ -241,7 +247,10 @@
#!BuildVersion: 15.6.29
FROM bci/bci-base:15.6
RUN zypper -n in --no-recommends gcc emacs; zypper -n clean; ##LOGCLEAN##
RUN \\
zypper -n install --no-recommends gcc emacs; \\
zypper -n clean; \\
##LOGCLEAN##
# Define labels according to https://en.opensuse.org/Building_derived_containers
# labelprefix=com.suse.bci.test
Expand Down Expand Up @@ -348,7 +357,10 @@
FROM suse/base:18
RUN zypper -n in --no-recommends gcc emacs; zypper -n clean; ##LOGCLEAN##
RUN \\
zypper -n install --no-recommends gcc emacs; \\
zypper -n clean; \\
##LOGCLEAN##
# Define labels according to https://en.opensuse.org/Building_derived_containers
# labelprefix=org.opensuse.bci.test
Expand Down

0 comments on commit d223369

Please sign in to comment.