@@ -6,41 +6,57 @@ ARG INSTALL_ROOT=/rootfs
66FROM opensuse/leap:${LEAP_VERSION} AS builder
77ARG CACHE_ZYPPER=/tmp/cache/zypper
88ARG INSTALL_ROOT
9-
10-
11- # /etc/os-release provides $VERSION_ID below.
12- # We don't need the openh264.repo and the non-oss repos, just costs build time (repo caches).
13-
14- RUN source /etc/os-release \
9+ RUN \
10+ # /etc/os-release provides ${VERSION_ID} for usage in ZYPPER_OPTIONS:
11+ source /etc/os-release \
12+ # We don't need the openh264.repo and the non-oss repos, just costs build time (repo caches).
1513 && zypper removerepo repo-openh264 repo-non-oss repo-update-non-oss \
1614 && export ZYPPER_OPTIONS=( --releasever "${VERSION_ID}" --installroot "${INSTALL_ROOT}" --cache-dir "${CACHE_ZYPPER}" ) \
1715 && zypper "${ZYPPER_OPTIONS[@]}" --gpg-auto-import-keys refresh \
1816 && zypper "${ZYPPER_OPTIONS[@]}" --non-interactive install --download-in-advance --no-recommends \
1917 bash procps grep gawk sed coreutils busybox ldns libidn2-0 socat openssl curl \
20- && zypper "${ZYPPER_OPTIONS[@]}" clean --all
21- # # Cleanup (reclaim approx 13 MiB):
22- # None of this content should be relevant to the container:
23- RUN rm -r "${INSTALL_ROOT}/usr/share/" {licenses,man,locale,doc,help,info}
24- # Functionality that the container doesn't need:
25- RUN rm "${INSTALL_ROOT}/usr/share/misc/termcap" \
26- && rm -r "${INSTALL_ROOT}/usr/lib/sysimage/rpm"
18+ && zypper "${ZYPPER_OPTIONS[@]}" clean --all \
19+ # # Cleanup (reclaim approx 13 MiB):
20+ # None of this content should be relevant to the container:
21+ && rm -r "${INSTALL_ROOT}/usr/share/" {licenses,man,locale,doc,help,info} \
22+ "${INSTALL_ROOT}/usr/share/misc/termcap" \
23+ "${INSTALL_ROOT}/usr/lib/sysimage/rpm"
2724
2825
29- # Create a new image with the contents of $INSTALL_ROOT
30- FROM scratch
26+ # Create a new image with the contents of ${ INSTALL_ROOT}
27+ FROM scratch AS base-leap
3128ARG INSTALL_ROOT
3229COPY --link --from=builder ${INSTALL_ROOT} /
33- # Link busybox to tar, see #2403. Create user + (home with SGID set):
34- RUN ln -s /usr/bin/busybox /usr/bin/tar \
30+ RUN \
31+ # Creates symlinks for any other commands that busybox can provide that
32+ # aren't already provided by coreutils (notably hexdump + tar, see #2403):
33+ # NOTE: `busybox --install -s` is not supported via the leap package, manually symlink commands.
34+ ln -s /usr/bin/busybox /usr/bin/tar \
3535 && ln -s /usr/bin/busybox /usr/bin/hexdump \
36+ && ln -s /usr/bin/busybox /usr/bin/xxd \
37+ # Add a non-root user `testssl`, this is roughly equivalent to the `useradd` command:
38+ # useradd --uid 1000 --user-group --create-home --shell /bin/bash testssl
3639 && echo 'testssl:x:1000:1000::/home/testssl:/bin/bash' >> /etc/passwd \
3740 && echo 'testssl:x:1000:' >> /etc/group \
3841 && echo 'testssl:!::0:::::' >> /etc/shadow \
3942 && install --mode 2755 --owner testssl --group testssl --directory /home/testssl \
40- && ln -s /home/testssl/testssl.sh /usr/local/bin/
43+ # The home directory will install a copy of `testssl.sh`, symlink the script to be used as a command:
44+ && ln -s /home/testssl/testssl.sh /usr/local/bin/testssl.sh
4145
42- # Copy over build context (after filtered by .dockerignore): bin/ etc/ testssl.sh
43- COPY --chown=testssl:testssl . /home/testssl/
46+ # Runtime config:
4447USER testssl
4548ENTRYPOINT ["testssl.sh" ]
4649CMD ["--help" ]
50+
51+ # Final image stage (add `testssl.sh` project files)
52+ # Choose either one as the final stage (defaults to last stage, `dist-local`)
53+
54+ # 62MB Image (Remote repo clone, cannot filter content through `.dockerignore`):
55+ FROM base-leap AS dist-git
56+ ARG GIT_URL=https://github.com/testssl/testssl.sh.git
57+ ARG GIT_BRANCH
58+ ADD --chown=testssl:testssl ${GIT_URL}#${GIT_BRANCH?branch-required} /home/testssl
59+
60+ # 54MB Image (Local repo copy from build context, uses `.dockerignore`):
61+ FROM base-leap AS dist-local
62+ COPY --chown=testssl:testssl . /home/testssl/
0 commit comments