Skip to content

Commit e0c3502

Browse files
authored
refactor: Docker (Alpine) improvements
60MB => 38MB (dist-git) or 30MB (dist-local)
1 parent 3a9746c commit e0c3502

1 file changed

Lines changed: 17 additions & 18 deletions

File tree

Dockerfile.git

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
# Build using git repo
2-
3-
FROM alpine:3.20
4-
5-
WORKDIR /home/testssl
6-
7-
ARG BUILD_VERSION
8-
ARG ARCHIVE_URL=https://github.com/testssl/testssl.sh/archive/
9-
ARG URL=https://github.com/testssl/testssl.sh.git
10-
11-
RUN test -n "${BUILD_VERSION}" \
12-
&& apk update \
13-
&& apk add --no-cache bash procps drill git coreutils libidn curl socat openssl xxd \
14-
&& git clone --depth 1 --branch ${BUILD_VERSION} $URL /home/testssl \
1+
FROM alpine:3.21 AS base-alpine
2+
RUN apk update \
3+
&& apk add --no-cache bash procps drill coreutils libidn curl socat openssl xxd \
154
&& addgroup testssl \
165
&& adduser -G testssl -g "testssl user" -s /bin/bash -D testssl \
17-
&& ln -s /home/testssl/testssl.sh /usr/local/bin/ \
18-
&& mkdir -m 755 -p /home/testssl/etc /home/testssl/bin
6+
&& ln -s /home/testssl/testssl.sh /usr/local/bin/testssl.sh
197

208
USER testssl
21-
229
ENTRYPOINT ["testssl.sh"]
23-
2410
CMD ["--help"]
11+
12+
# Final image stage (add testssl.sh project files)
13+
# Choose either one as the final stage (defaults to last stage, `dist-git`)
14+
15+
# 30MB Image (Local repo copy from build context, uses `.dockerignore`):
16+
FROM base-alpine AS dist-local
17+
COPY --chown=testssl:testssl . /home/testssl/
18+
19+
# 38MB Image (Remote repo clone, cannot filter content through `.dockerignore`):
20+
FROM base-alpine AS dist-git
21+
ARG GIT_URL=https://github.com/testssl/testssl.sh.git
22+
ARG GIT_BRANCH
23+
ADD --chown=testssl:testssl ${GIT_URL}#${GIT_BRANCH?branch-required} /home/testssl

0 commit comments

Comments
 (0)