|
1 | | -FROM alpine:3.17 |
| 1 | +# syntax=docker.io/docker/dockerfile:1 |
2 | 2 |
|
3 | | -RUN apk update && \ |
4 | | - apk upgrade && \ |
5 | | - apk add bash procps drill git coreutils libidn curl socat openssl xxd && \ |
6 | | - rm -rf /var/cache/apk/* && \ |
7 | | - adduser -D -s /bin/bash testssl && \ |
8 | | - ln -s /home/testssl/testssl.sh /usr/local/bin/ |
| 3 | +ARG LEAP_VERSION=15.4 |
| 4 | +ARG INSTALL_ROOT=/rootfs |
9 | 5 |
|
10 | | -USER testssl |
11 | | -WORKDIR /home/testssl/ |
| 6 | +FROM opensuse/leap:${LEAP_VERSION} as builder |
| 7 | +ARG CACHE_ZYPPER=/tmp/cache/zypper |
| 8 | +ARG INSTALL_ROOT |
| 9 | +# /etc/os-release provides $VERSION_ID |
| 10 | +RUN source /etc/os-release \ |
| 11 | + && export ZYPPER_OPTIONS=( --releasever "${VERSION_ID}" --installroot "${INSTALL_ROOT}" --cache-dir "${CACHE_ZYPPER}" ) \ |
| 12 | + && zypper "${ZYPPER_OPTIONS[@]}" --gpg-auto-import-keys refresh \ |
| 13 | + && zypper "${ZYPPER_OPTIONS[@]}" --non-interactive install --download-in-advance --no-recommends \ |
| 14 | + bash procps grep gawk sed coreutils busybox-util-linux busybox-vi ldns libidn2-0 socat openssl curl \ |
| 15 | + && zypper "${ZYPPER_OPTIONS[@]}" clean --all |
| 16 | +## Cleanup (reclaim approx 13 MiB): |
| 17 | +# None of this content should be relevant to the container: |
| 18 | +RUN rm -r "${INSTALL_ROOT}/usr/share/"{licenses,man,locale,doc,help,info} |
| 19 | +# Functionality that the container doesn't need: |
| 20 | +RUN rm "${INSTALL_ROOT}/usr/share/misc/termcap" \ |
| 21 | + && rm -r "${INSTALL_ROOT}/usr/lib/sysimage/rpm" |
| 22 | + |
| 23 | + |
| 24 | +# Create a new image with the contents of $INSTALL_ROOT |
| 25 | +FROM scratch |
| 26 | +ARG INSTALL_ROOT |
| 27 | +COPY --link --from=builder ${INSTALL_ROOT} / |
| 28 | +# Create user + (home with SGID set): |
| 29 | +RUN echo 'testssl:x:1000:1000::/home/testssl:/bin/bash' >> /etc/passwd \ |
| 30 | + && echo 'testssl:x:1000:' >> /etc/group \ |
| 31 | + && echo 'testssl:!::0:::::' >> /etc/shadow \ |
| 32 | + && install --mode 2755 --owner testssl --group testssl --directory /home/testssl \ |
| 33 | + && ln -s /home/testssl/testssl.sh /usr/local/bin/ |
12 | 34 |
|
13 | 35 | # Copy over build context (after filtered by .dockerignore): bin/ etc/ testssl.sh |
14 | 36 | COPY --chown=testssl:testssl . /home/testssl/ |
15 | | - |
| 37 | +USER testssl |
16 | 38 | ENTRYPOINT ["testssl.sh"] |
17 | | - |
18 | 39 | CMD ["--help"] |
0 commit comments