refactor: Docker (Alpine) improvements #2752
Merged
+16
−18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe your changes
Applying changes that I detailed in this comment.
Alpine image size reduced from 60MB (technically 52MB) to 36MB (
dist-git
) or 28MB (dist-local
).Change overview:
WORKDIR /home/testssl
to be consistent with the mainDockerfile
which leaves working directory at default/
.apk update
is not needed, if run with--no-cache
in a separateRUN
it has no layer weight. Removing it or adding--no-cache
reduces weight by 2MB.git
package +git clone
command, no longer necessary. Reduces weight by 14MB+mkdir -m 755 -p /home/testssl/etc /home/testssl/bin
, these already exist with expected permissions via the clone.ARG
renamed and relocated to end of file at thedist-git
stage. Technically a breaking change, perhaps theARG
names should be kept the same?dist-local
stage that usesCOPY
for a local clone like the mainDockerfile
does (reduces weight by 8MB). Whiledist-git
stage usesADD
to perform a remote git clone.Some of these changes were attempted back in Feb 2023 for
Dockerfile
(when it was still Alpine based). That PR provides additional information to support these changesapk add --no-cache
implyingapk update
.git
package and.git/
dir which loses thegit log
feature to identifytestssl.sh
version via commit hash.Related caveat with Alpine image in the past was incompatibility with the OpenSSL bins (glibc) that are copied over into the image, since even with a static glibc build, glibc static is known to have compatibility caveats when it comes to DNS logic (looking through issue history on DNS /
getaddrinfo
, there was since talk about segfaults that required a newer static compile that resolved it, so maybe not a DNS musl issue at these linked comments):What is your pull request about?