2023-03-22 09:18:36 +01:00
|
|
|
# syntax=docker.io/docker/dockerfile:1
|
2023-03-22 09:31:34 +01:00
|
|
|
|
2023-03-22 09:18:36 +01:00
|
|
|
ARG LEAP_VERSION=15.4
|
|
|
|
ARG INSTALL_ROOT=/rootfs
|
2017-03-30 13:18:46 +02:00
|
|
|
|
2023-03-22 09:18:36 +01:00
|
|
|
FROM opensuse/leap:${LEAP_VERSION} as builder
|
2023-03-22 09:31:34 +01:00
|
|
|
ARG CACHE_ZYPPER=/tmp/cache/zypper
|
2023-03-22 09:18:36 +01:00
|
|
|
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 <<EOF
|
|
|
|
# Provides $VERSION_ID
|
|
|
|
source /etc/os-release
|
|
|
|
ZYPPER_OPTIONS=(
|
|
|
|
--releasever "${VERSION_ID}"
|
|
|
|
--installroot "${INSTALL_ROOT}"
|
|
|
|
--cache-dir "${CACHE_ZYPPER}"
|
|
|
|
)
|
|
|
|
|
2023-03-22 09:31:34 +01:00
|
|
|
# Sync package repos:
|
2023-03-22 09:18:36 +01:00
|
|
|
zypper ${ZYPPER_OPTIONS[@]} --gpg-auto-import-keys refresh
|
|
|
|
|
|
|
|
zypper ${ZYPPER_OPTIONS[@]} --non-interactive install \
|
2023-03-22 09:31:34 +01:00
|
|
|
--download-in-advance --no-recommends \
|
|
|
|
bash procps grep gawk sed coreutils busybox-util-linux busybox-vi ldns libidn2-0 socat openssl curl
|
2023-03-22 09:18:36 +01:00
|
|
|
|
|
|
|
|
2023-03-22 09:31:34 +01:00
|
|
|
## Cleanup (reclaim approx 13 MiB):
|
|
|
|
# None of this content should be relevant to the container:
|
2023-03-22 09:18:36 +01:00
|
|
|
rm -r "${INSTALL_ROOT}/usr/share/"{licenses,man,locale,doc,help,info}
|
2023-03-22 09:31:34 +01:00
|
|
|
# Functionality that the container doesn't need:
|
2023-03-22 09:18:36 +01:00
|
|
|
rm "${INSTALL_ROOT}/usr/share/misc/termcap"
|
|
|
|
rm -r "${INSTALL_ROOT}/usr/lib/sysimage/rpm"
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
# Create a new image with the contents of $INSTALL_ROOT
|
|
|
|
FROM scratch
|
|
|
|
ARG INSTALL_ROOT
|
|
|
|
COPY --link --from=builder ${INSTALL_ROOT} /
|
2023-03-22 09:16:50 +01:00
|
|
|
WORKDIR /home/testssl
|
|
|
|
RUN --mount=type=bind,from=busybox:latest,source=/bin,target=/bin <<EOF
|
|
|
|
/bin/adduser -D -s /bin/bash testssl
|
|
|
|
/bin/ln -s /home/testssl/testssl.sh /usr/local/bin/
|
2023-03-22 09:18:36 +01:00
|
|
|
EOF
|
2017-03-30 13:18:46 +02:00
|
|
|
|
2023-01-31 07:58:17 +01:00
|
|
|
# Copy over build context (after filtered by .dockerignore): bin/ etc/ testssl.sh
|
2023-02-07 09:36:47 +01:00
|
|
|
COPY --chown=testssl:testssl . /home/testssl/
|
2023-03-22 09:16:50 +01:00
|
|
|
USER testssl
|
2018-02-08 21:06:19 +01:00
|
|
|
ENTRYPOINT ["testssl.sh"]
|
2017-03-30 14:41:46 +02:00
|
|
|
CMD ["--help"]
|