Skip to content

Commit cfc4b30

Browse files
committed
build: initcontainers: have base image specific toybox config
Our *.Dockefile's allow builders to specify FINAL_BASE base image to which static binaries are copied for the final image. Initcontainers install toybox with a minimum set of "coreutils" needed but with some final base images the minimum set can be even smaller since they may already have /bin/sh, ls etc. installed. Make initcontainers to have base image specific toybox-config. For now, "static" for distroles/static and "ubi8-micro" for UBI base image configs are created. At the same time, move the toybox build to "usrmerge" based setup where everything is installed to /usr/bin and /bin is a symlink to /usr/bin. buildkit does not seem to like it so disable buildkit usage for now. Signed-off-by: Mikko Ylinen <[email protected]>
1 parent 922f145 commit cfc4b30

9 files changed

+409
-7
lines changed

build/docker/build-image.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fi
3131

3232
BUILD_ARGS="${BUILD_ARGS} --build-arg FINAL_BASE=gcr.io/distroless/static"
3333
if [ -z "${BUILDER}" -o "${BUILDER}" = 'docker' -o "${BUILDER}" = 'podman' ] ; then
34-
${BUILDER} build --pull -t ${IMG}:${TAG} ${BUILD_ARGS} -f ${DOCKERFILE} .
34+
DOCKER_BUILDKIT=0 ${BUILDER} build --pull -t ${IMG}:${TAG} ${BUILD_ARGS} -f ${DOCKERFILE} .
3535
elif [ "${BUILDER}" = 'buildah' ] ; then
3636
BUILDAH_RUNTIME=runc buildah bud --pull-always -t ${IMG}:${TAG} ${BUILD_ARGS} -f ${DOCKERFILE} .
3737
else

build/docker/intel-dlb-initcontainer.Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ ARG TOYBOX_SHA256="3c31e235fe87e74e6c6cf7cd7299fcbffb0f4a4834dae607aa26bb4f15835
4444
ARG ROOT=/install_root
4545
RUN apt-get update && apt-get --no-install-recommends -y install musl musl-tools musl-dev
4646
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
47+
ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest
4748
RUN curl -SL https://github.com/landley/toybox/archive/refs/tags/$TOYBOX_VERSION.tar.gz -o toybox.tar.gz \
4849
&& echo "$TOYBOX_SHA256 toybox.tar.gz" | sha256sum -c - \
4950
&& tar -xzf toybox.tar.gz \
5051
&& rm toybox.tar.gz \
5152
&& cd toybox-$TOYBOX_VERSION \
52-
&& KCONFIG_CONFIG=${DIR}/build/docker/toybox-config LDFLAGS="--static" CC=musl-gcc PREFIX=$ROOT V=2 make toybox install \
53+
&& KCONFIG_CONFIG=${DIR}/build/docker/toybox-config-$(echo ${FINAL_BASE} | xargs basename -s :latest) LDFLAGS="--static" CC=musl-gcc PREFIX=$ROOT/usr/bin V=2 make toybox install_flat \
54+
&& cd $ROOT && ln -fs usr/bin bin && cd - \
5355
&& install -D LICENSE $ROOT/licenses/toybox \
5456
&& cp -r /usr/share/doc/musl $ROOT/licenses/
5557
###

build/docker/intel-fpga-initcontainer.Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,14 @@ ARG TOYBOX_SHA256="3c31e235fe87e74e6c6cf7cd7299fcbffb0f4a4834dae607aa26bb4f15835
7575
ARG ROOT=/install_root
7676
RUN apt-get update && apt-get --no-install-recommends -y install musl musl-tools musl-dev
7777
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
78+
ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest
7879
RUN curl -SL https://github.com/landley/toybox/archive/refs/tags/$TOYBOX_VERSION.tar.gz -o toybox.tar.gz \
7980
&& echo "$TOYBOX_SHA256 toybox.tar.gz" | sha256sum -c - \
8081
&& tar -xzf toybox.tar.gz \
8182
&& rm toybox.tar.gz \
8283
&& cd toybox-$TOYBOX_VERSION \
83-
&& KCONFIG_CONFIG=${DIR}/build/docker/toybox-config LDFLAGS="--static" CC=musl-gcc PREFIX=$ROOT V=2 make toybox install \
84+
&& KCONFIG_CONFIG=${DIR}/build/docker/toybox-config-$(echo ${FINAL_BASE} | xargs basename -s :latest) LDFLAGS="--static" CC=musl-gcc PREFIX=$ROOT/usr/bin V=2 make toybox install_flat \
85+
&& cd $ROOT && ln -fs usr/bin bin && cd - \
8486
&& install -D LICENSE $ROOT/licenses/toybox \
8587
&& cp -r /usr/share/doc/musl $ROOT/licenses/
8688
###

build/docker/intel-gpu-initcontainer.Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ ARG TOYBOX_SHA256="3c31e235fe87e74e6c6cf7cd7299fcbffb0f4a4834dae607aa26bb4f15835
5858
ARG ROOT=/install_root
5959
RUN apt-get update && apt-get --no-install-recommends -y install musl musl-tools musl-dev
6060
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
61+
ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest
6162
RUN curl -SL https://github.com/landley/toybox/archive/refs/tags/$TOYBOX_VERSION.tar.gz -o toybox.tar.gz \
6263
&& echo "$TOYBOX_SHA256 toybox.tar.gz" | sha256sum -c - \
6364
&& tar -xzf toybox.tar.gz \
6465
&& rm toybox.tar.gz \
6566
&& cd toybox-$TOYBOX_VERSION \
66-
&& KCONFIG_CONFIG=${DIR}/build/docker/toybox-config LDFLAGS="--static" CC=musl-gcc PREFIX=$ROOT V=2 make toybox install \
67+
&& KCONFIG_CONFIG=${DIR}/build/docker/toybox-config-$(echo ${FINAL_BASE} | xargs basename -s :latest) LDFLAGS="--static" CC=musl-gcc PREFIX=$ROOT/usr/bin V=2 make toybox install_flat \
68+
&& cd $ROOT && ln -fs usr/bin bin && cd - \
6769
&& install -D LICENSE $ROOT/licenses/toybox \
6870
&& cp -r /usr/share/doc/musl $ROOT/licenses/
6971
###

build/docker/intel-qat-initcontainer.Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ ARG TOYBOX_SHA256="3c31e235fe87e74e6c6cf7cd7299fcbffb0f4a4834dae607aa26bb4f15835
4444
ARG ROOT=/install_root
4545
RUN apt-get update && apt-get --no-install-recommends -y install musl musl-tools musl-dev
4646
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
47+
ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest
4748
RUN curl -SL https://github.com/landley/toybox/archive/refs/tags/$TOYBOX_VERSION.tar.gz -o toybox.tar.gz \
4849
&& echo "$TOYBOX_SHA256 toybox.tar.gz" | sha256sum -c - \
4950
&& tar -xzf toybox.tar.gz \
5051
&& rm toybox.tar.gz \
5152
&& cd toybox-$TOYBOX_VERSION \
52-
&& KCONFIG_CONFIG=${DIR}/build/docker/toybox-config LDFLAGS="--static" CC=musl-gcc PREFIX=$ROOT V=2 make toybox install \
53+
&& KCONFIG_CONFIG=${DIR}/build/docker/toybox-config-$(echo ${FINAL_BASE} | xargs basename -s :latest) LDFLAGS="--static" CC=musl-gcc PREFIX=$ROOT/usr/bin V=2 make toybox install_flat \
54+
&& cd $ROOT && ln -fs usr/bin bin && cd - \
5355
&& install -D LICENSE $ROOT/licenses/toybox \
5456
&& cp -r /usr/share/doc/musl $ROOT/licenses/
5557
###

build/docker/intel-sgx-initcontainer.Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ ARG TOYBOX_SHA256="3c31e235fe87e74e6c6cf7cd7299fcbffb0f4a4834dae607aa26bb4f15835
5858
ARG ROOT=/install_root
5959
RUN apt-get update && apt-get --no-install-recommends -y install musl musl-tools musl-dev
6060
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
61+
ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest
6162
RUN curl -SL https://github.com/landley/toybox/archive/refs/tags/$TOYBOX_VERSION.tar.gz -o toybox.tar.gz \
6263
&& echo "$TOYBOX_SHA256 toybox.tar.gz" | sha256sum -c - \
6364
&& tar -xzf toybox.tar.gz \
6465
&& rm toybox.tar.gz \
6566
&& cd toybox-$TOYBOX_VERSION \
66-
&& KCONFIG_CONFIG=${DIR}/build/docker/toybox-config LDFLAGS="--static" CC=musl-gcc PREFIX=$ROOT V=2 make toybox install \
67+
&& KCONFIG_CONFIG=${DIR}/build/docker/toybox-config-$(echo ${FINAL_BASE} | xargs basename -s :latest) LDFLAGS="--static" CC=musl-gcc PREFIX=$ROOT/usr/bin V=2 make toybox install_flat \
68+
&& cd $ROOT && ln -fs usr/bin bin && cd - \
6769
&& install -D LICENSE $ROOT/licenses/toybox \
6870
&& cp -r /usr/share/doc/musl $ROOT/licenses/
6971
###

build/docker/lib/toybox_build.docker

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ ARG ROOT=/install_root
55

66
RUN apt-get update && apt-get --no-install-recommends -y install musl musl-tools musl-dev
77
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
8+
ARG FINAL_BASE=registry.access.redhat.com/ubi9-micro:latest
89
RUN curl -SL https://github.com/landley/toybox/archive/refs/tags/$TOYBOX_VERSION.tar.gz -o toybox.tar.gz \N
910
&& echo "$TOYBOX_SHA256 toybox.tar.gz" | sha256sum -c - \N
1011
&& tar -xzf toybox.tar.gz \N
1112
&& rm toybox.tar.gz \N
1213
&& cd toybox-$TOYBOX_VERSION \N
13-
&& KCONFIG_CONFIG=${DIR}/build/docker/toybox-config LDFLAGS="--static" CC=musl-gcc PREFIX=$ROOT V=2 make toybox install \N
14+
&& KCONFIG_CONFIG=${DIR}/build/docker/toybox-config-$(echo ${FINAL_BASE} | xargs basename -s :latest) LDFLAGS="--static" CC=musl-gcc PREFIX=$ROOT/usr/bin V=2 make toybox install_flat \N
15+
&& cd $ROOT && ln -fs usr/bin bin && cd - \N
1416
&& install -D LICENSE $ROOT/licenses/toybox \N
1517
&& cp -r /usr/share/doc/musl $ROOT/licenses/
1618
###
File renamed without changes.

0 commit comments

Comments
 (0)