@@ -6,50 +6,61 @@ ARG INSTALL_ROOT=/rootfs
66FROM opensuse/leap:${LEAP_VERSION} AS builder
77ARG CACHE_ZYPPER=/tmp/cache/zypper
88ARG INSTALL_ROOT
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).
13- && zypper removerepo repo-openh264 repo-non-oss repo-update-non-oss \
14- && export ZYPPER_OPTIONS=( --releasever "${VERSION_ID}" --installroot "${INSTALL_ROOT}" --cache-dir "${CACHE_ZYPPER}" ) \
15- && zypper "${ZYPPER_OPTIONS[@]}" --gpg-auto-import-keys refresh \
16- && zypper "${ZYPPER_OPTIONS[@]}" --non-interactive install --download-in-advance --no-recommends \
17- bash procps grep gawk sed coreutils busybox ldns libidn2-0 socat openssl curl \
18- && zypper "${ZYPPER_OPTIONS[@]}" clean --all \
19- # # Cleanup (reclaim approx 13 MiB):
9+ RUN <<HEREDOC
10+ # Remove the `openh264` the `non-oss` repos to save on sync time, they're not needed:
11+ zypper removerepo repo-openh264 repo-non-oss repo-update-non-oss
12+ # `/etc/os-release` provides the `VERSION_ID` variable for usage in `ZYPPER_OPTIONS`:
13+ source /etc/os-release
14+ export ZYPPER_OPTIONS=( --releasever "${VERSION_ID}" --installroot "${INSTALL_ROOT}" --cache-dir "${CACHE_ZYPPER}" )
15+
16+ # Install packages to a custom root-fs location (defined in `ZYPPER_OPTIONS`):
17+ zypper "${ZYPPER_OPTIONS[@]}" --gpg-auto-import-keys refresh
18+ zypper "${ZYPPER_OPTIONS[@]}" --non-interactive install --download-in-advance --no-recommends \
19+ bash procps grep gawk sed coreutils busybox ldns libidn2-0 socat openssl curl
20+
21+ # Optional - Avoid `CACHE_ZYPPER` from being redundantly cached in this RUN layer:
22+ # (doesn't improve `INSTALL_ROOT` size thanks to `--cache-dir`)
23+ zypper "${ZYPPER_OPTIONS[@]}" clean --all
24+
25+ # Cleanup (reclaim approx 13 MiB):
2026 # 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"
27+ rm -r "${INSTALL_ROOT}/usr/share/" {licenses,man,locale,doc,help,info} \
28+ "${INSTALL_ROOT}/usr/share/misc/termcap" \
29+ "${INSTALL_ROOT}/usr/lib/sysimage/rpm"
30+ HEREDOC
2431
2532
2633# Create a new image with the contents of ${INSTALL_ROOT}
2734FROM scratch AS base-leap
2835ARG INSTALL_ROOT
2936COPY --link --from=builder ${INSTALL_ROOT} /
30- RUN \
37+ RUN <<HEREDOC
3138 # Creates symlinks for any other commands that busybox can provide that
3239 # aren't already provided by coreutils (notably hexdump + tar, see #2403):
3340 # NOTE: `busybox --install -s` is not supported via the leap package, manually symlink commands.
34- ln -s /usr/bin/busybox /usr/bin/tar \
35- && ln -s /usr/bin/busybox /usr/bin/hexdump \
36- && ln -s /usr/bin/busybox /usr/bin/xxd \
41+ ln -s /usr/bin/busybox /usr/bin/tar
42+ ln -s /usr/bin/busybox /usr/bin/hexdump
43+ ln -s /usr/bin/busybox /usr/bin/xxd
44+
3745 # Add a non-root user `testssl`, this is roughly equivalent to the `useradd` command:
3846 # useradd --uid 1000 --user-group --create-home --shell /bin/bash testssl
39- && echo 'testssl:x:1000:1000::/home/testssl:/bin/bash' >> /etc/passwd \
40- && echo 'testssl:x:1000:' >> /etc/group \
41- && echo 'testssl:!::0:::::' >> /etc/shadow \
42- && install --mode 2755 --owner testssl --group testssl --directory /home/testssl \
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
47+ echo 'testssl:x:1000:1000::/home/testssl:/bin/bash' >> /etc/passwd
48+ echo 'testssl:x:1000:' >> /etc/group
49+ echo 'testssl:!::0:::::' >> /etc/shadow
50+ install --mode 2755 --owner testssl --group testssl --directory /home/testssl
51+
52+ # A copy of `testssl.sh` will be added to the home directory,
53+ # symlink to that file so it can be treated as a command:
54+ ln -s /home/testssl/testssl.sh /usr/local/bin/testssl.sh
55+ HEREDOC
4556
4657# Runtime config:
4758USER testssl
4859ENTRYPOINT ["testssl.sh" ]
4960CMD ["--help" ]
5061
5162# Final image stage (add `testssl.sh` project files)
52- # Choose either one as the final stage (defaults to last stage, `dist-local`)
63+ # Choose either one as the final stage (defaults to the last stage, `dist-local`)
5364
5465# 62MB Image (Remote repo clone, cannot filter content through `.dockerignore`):
5566FROM base-leap AS dist-git
0 commit comments