Skip to content

Commit 252cee6

Browse files
authored
Merge pull request #2752 from polarathene/patch-1
refactor: Docker (Alpine) improvements
2 parents 3a9746c + 0b4b2d9 commit 252cee6

1 file changed

Lines changed: 16 additions & 18 deletions

File tree

Dockerfile.git

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
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 add --no-cache bash procps drill coreutils libidn curl socat openssl xxd \
153
&& addgroup testssl \
164
&& 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
5+
&& ln -s /home/testssl/testssl.sh /usr/local/bin/testssl.sh
196

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

0 commit comments

Comments
 (0)