From 1212ad8e59e683306a5e34496b53c5361c3f785c Mon Sep 17 00:00:00 2001 From: Brennan Kinney <5098581+polarathene@users.noreply.github.com> Date: Wed, 22 Mar 2023 22:13:18 +1300 Subject: [PATCH] refactor: Support syntax without BuildKit features These have been available via opt-in prior to v23 of Docker Engine with `DOCKER_BUILDKIT=1` ENV as a prefix to running `docker build`, however it's been requested to avoid the syntax. No HereDoc (multi-line RUN with EOF marker) or `RUN --mount` available. This makes the `busybox` approach a hassle, so I've brought back the explicit creation of user and home dir. Without the cache mounts, bring back `zypper clean`. It's not doing much as the `--cache-dir` is still set, but should reduce disk space for the `builder` layer. Local builds will be slower as a result when this layer is invalidated. AFAIK, this also makes it tricky to use the `ZYPPER_OPTIONS`? So no longer DRY. --- Dockerfile | 54 ++++++++++++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index c041ccb..c4af7ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,44 +6,34 @@ ARG INSTALL_ROOT=/rootfs FROM opensuse/leap:${LEAP_VERSION} as builder ARG CACHE_ZYPPER=/tmp/cache/zypper ARG INSTALL_ROOT -# --mount is only necessary for persisting the zypper cache on the build host, -# Paired with --cache-dir below, RUN layer invalidation does not clear this cache. -# Not useful for CI, only local builds that retain the storage. -RUN --mount=type=cache,target="${CACHE_ZYPPER}",sharing=locked <> /etc/passwd \ + && echo 'testssl:x:1000:' >> /etc/group \ + && echo 'testssl:!::0:::::' >> /etc/shadow \ + && install --mode 2755 --owner testssl --group testssl --directory /home/testssl \ + && ln -s /home/testssl/testssl.sh /usr/local/bin/ # Copy over build context (after filtered by .dockerignore): bin/ etc/ testssl.sh COPY --chown=testssl:testssl . /home/testssl/