Hi gents,
Building the docker image with DEBIAN_TAG=bullseye-slim, fails with
python3-kconfiglib and python3-shtab packages not available
pip3 install does not know --break-system-packages yet
This change adds two intermediate conditional layers before the kas-base
layer in which the differences are handled based on what Debian version
we're dealing with.
github PR:
https://github.com/siemens/kas/pull/119
Cheers
Mehmet
From ecd6008e04aa228c55df9fda7898a15e67890438 Mon Sep 17 00:00:00 2001
From: Mehmet Bulut <
ma...@mehmetbulut.de>
Date: Sun, 26 May 2024 06:52:15 +0200
Subject: [PATCH] Dockerfile: Fix broken bullseye based build
---
Dockerfile | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index dfebca2..1ae3b24 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -23,7 +23,7 @@
ARG DEBIAN_TAG=bookworm-slim
-FROM debian:${DEBIAN_TAG} as kas-base
+FROM debian:${DEBIAN_TAG} as kas-base-conditional
ARG SOURCE_DATE_EPOCH
ARG CACHE_SHARING=locked
@@ -48,10 +48,10 @@ RUN
--mount=type=cache,target=/var/cache/apt,sharing=${CACHE_SHARING} \
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias
en_US.UTF-8 && \
apt-get install --no-install-recommends -y \
python3-pip python3-setuptools python3-wheel python3-yaml
python3-distro python3-jsonschema \
- python3-newt python3-colorlog python3-kconfiglib
python3-websockets \
+ python3-newt python3-colorlog python3-websockets \
gosu lsb-release file vim less procps tree tar bzip2 zstd pigz
lz4 unzip tmux libncurses-dev \
git-lfs mercurial iproute2 ssh-client telnet curl rsync gnupg
awscli sudo \
- socat bash-completion python3-shtab python3-git && \
+ socat bash-completion python3-git && \
rm -rf /var/log/* /tmp/* /var/tmp/* /var/cache/ldconfig/aux-cache && \
rm -f /etc/gitconfig && \
git config --system filter.lfs.clean 'git-lfs clean -- %f' && \
@@ -59,12 +59,23 @@ RUN
--mount=type=cache,target=/var/cache/apt,sharing=${CACHE_SHARING} \
git config --system filter.lfs.process 'git-lfs filter-process' && \
git config --system filter.lfs.required true
+FROM kas-base-conditional as kas-base-bookworm-slim
+RUN apt-get update && \
+ apt-get install --no-install-recommends -y python3-kconfiglib
python3-shtab
+ENV PIP3_EXTRA_ARGS="--break-system-packages"
+FROM kas-base-conditional as kas-base-bullseye-slim
+RUN curl
http://ftp.de.debian.org/debian/pool/main/k/kconfiglib/python3-kconfiglib_14.1.0-3_all.deb
-o /tmp/python3-kconfiglib.deb && \
+ curl
http://ftp.de.debian.org/debian/pool/main/p/python-shtab/python3-shtab_1.5.5-3_all.deb
-o /tmp/python3-shtab.deb && \
+ dpkg -i /tmp/python3-kconfiglib.deb /tmp/python3-shtab.deb && \
+ rm /tmp/python3-kconfiglib.deb /tmp/python3-shtab.deb
+FROM kas-base-${DEBIAN_TAG} as kas-base
+
COPY . /kas
RUN pip3 --proxy=$https_proxy install \
--no-deps \
--no-build-isolation \
- --break-system-packages \
+ ${PIP3_EXTRA_ARGS} \
/kas && \
install -d /usr/local/share/bash-completion/completions/ && \
shtab --shell=bash -u kas.kas.kas_get_argparser
--error-unimportable --prog kas \
--
2.34.1