diff options
Diffstat (limited to '')
-rw-r--r-- | Dockerfile | 40 | ||||
-rw-r--r-- | Dockerfile.git | 24 | ||||
-rw-r--r-- | Dockerfile.md | 49 |
3 files changed, 113 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1428352 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +# syntax=docker.io/docker/dockerfile:1 + +ARG LEAP_VERSION=15.4 +ARG INSTALL_ROOT=/rootfs + +FROM opensuse/leap:${LEAP_VERSION} as builder +ARG CACHE_ZYPPER=/tmp/cache/zypper +ARG INSTALL_ROOT +# /etc/os-release provides $VERSION_ID +RUN source /etc/os-release \ + && export ZYPPER_OPTIONS=( --releasever "${VERSION_ID}" --installroot "${INSTALL_ROOT}" --cache-dir "${CACHE_ZYPPER}" ) \ + && zypper "${ZYPPER_OPTIONS[@]}" --gpg-auto-import-keys refresh \ + && zypper "${ZYPPER_OPTIONS[@]}" --non-interactive install --download-in-advance --no-recommends \ + bash procps grep gawk sed coreutils busybox-util-linux busybox-vi ldns libidn2-0 socat openssl curl \ + && zypper "${ZYPPER_OPTIONS[@]}" clean --all +## Cleanup (reclaim approx 13 MiB): +# None of this content should be relevant to the container: +RUN rm -r "${INSTALL_ROOT}/usr/share/"{licenses,man,locale,doc,help,info} +# Functionality that the container doesn't need: +RUN rm "${INSTALL_ROOT}/usr/share/misc/termcap" \ + && rm -r "${INSTALL_ROOT}/usr/lib/sysimage/rpm" + + +# Create a new image with the contents of $INSTALL_ROOT +FROM scratch +ARG INSTALL_ROOT +COPY --link --from=builder ${INSTALL_ROOT} / +# Link busybox to tar, see #2403. Create user + (home with SGID set): +RUN ln -s /usr/bin/busybox /usr/bin/tar \ + && echo 'testssl:x:1000:1000::/home/testssl:/bin/bash' >> /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/ +USER testssl +ENTRYPOINT ["testssl.sh"] +CMD ["--help"] diff --git a/Dockerfile.git b/Dockerfile.git new file mode 100644 index 0000000..6411a17 --- /dev/null +++ b/Dockerfile.git @@ -0,0 +1,24 @@ +# Build using git repo + +FROM alpine:3.17 + +WORKDIR /home/testssl + +ARG BUILD_VERSION +ARG ARCHIVE_URL=https://github.com/drwetter/testssl.sh/archive/ +ARG URL=https://github.com/drwetter/testssl.sh.git + +RUN test -n "${BUILD_VERSION}" \ + && apk update \ + && apk add --no-cache bash procps drill git coreutils libidn curl socat openssl xxd \ + && git clone --depth 1 --branch ${BUILD_VERSION} $URL /home/testssl \ + && addgroup testssl \ + && adduser -G testssl -g "testssl user" -s /bin/bash -D testssl \ + && ln -s /home/testssl/testssl.sh /usr/local/bin/ \ + && mkdir -m 755 -p /home/testssl/etc /home/testssl/bin + +USER testssl + +ENTRYPOINT ["testssl.sh"] + +CMD ["--help"] diff --git a/Dockerfile.md b/Dockerfile.md new file mode 100644 index 0000000..27ab6b0 --- /dev/null +++ b/Dockerfile.md @@ -0,0 +1,49 @@ +## Usage + +### From git directory + +``` +docker build . +``` + +Catch is when you run without image tags you need to catch the ID when building + +``` +[..] +---> 889fa2f99933 +Successfully built 889fa2f99933 +``` + +More comfortable is + +``` +docker build -t mytestssl . +docker run --rm -t mytestssl example.com +``` + +You can also supply command line options like: + +``` +docker run -t mytestssl --help +docker run --rm -t mytestssl -p --header example.com +``` + +### From dockerhub + +You can pull the image from dockerhub and run: + +``` +docker run --rm -t drwetter/testssl.sh --fs example.com +``` + +Supported tags are: ``3.2`` and ``latest`, which are the same, i.e. the rolling release. ``3.0`` is the latest stable version from git which might have a few improvements (see git log) over the released version 3.0.X. + +``docker run --rm -t drwetter/testssl.sh:stable example.com``. + +Keep in mind that any output file (--log, --html, --json etc.) will be created within the container. If you wish to have this created in a local directory on your host you can mount a volume into the container and change the output prefix where the container user has write access to, e.g.: + +``` +docker run --rm -t -v /tmp:/data drwetter/testssl.sh --htmlfile /data/ example.com +``` + +which writes the HTML output to ``/tmp/example.com_p443-<date>-<time>.html.`` The uid/gid is the one from the docker user. Normally the file is 644. testssl.sh's docker container uses a non-root user (usually with user/groupid 1000:1000). |