Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply some best practices to Dockerfile #3

Merged
merged 1 commit into from
Oct 27, 2022
Merged

Conversation

mark-rushakoff
Copy link
Member

Use alpine image instead of golang for earliest stage, which did not use anything from the golang image.

Use apk add --no-cache per convention inside Dockerfiles, which does not store apk's package cache on disk. This reduced the final image size by about 3MB.

Move apk add package arguments to their own lines, so that diffs are trivial to follow as individual packages are added or removed.

Validate checksum of downloaded dasel binary, to avoid a potential supply chain attack.

Further possible improvements:

  • Validate checksum of musl download
  • Maybe point at a fixed tag of boxboat/config-merge
  • Maybe download gzipped dasel binaries instead of raw binaries
  • Update to newer point release of dasel
  • Unify the two Dockerfiles by a top-level build arg to switch between the alternative "busybox-min" stages

Use alpine image instead of golang for earliest stage, which did not use
anything from the golang image.

Use apk add --no-cache per convention inside Dockerfiles, which does not
store apk's package cache on disk. This reduced the final image size by
about 3MB.

Move apk add package arguments to their own lines, so that diffs are
trivial to follow as individual packages are added or removed.

Validate checksum of downloaded dasel binary, to avoid a potential
supply chain attack.

Further possible improvements:

- Validate checksum of musl download
- Maybe point at a fixed tag of boxboat/config-merge
- Maybe download gzipped dasel binaries instead of raw binaries
- Update to newer point release of dasel
- Unify the two Dockerfiles by a top-level build arg to switch between
  the alternative "busybox-min" stages
@@ -39,7 +48,13 @@ FROM boxboat/config-merge:latest as config-merge

FROM golang:1.19-alpine
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I think about it, there doesn't seem to be a reason to have golang in the final image either

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was guessing that it was important for downstream builders. I'll open a followup PR for that, in case it ends up breaking anything (unlikely).

@mark-rushakoff mark-rushakoff merged commit eb88abe into main Oct 27, 2022
@mark-rushakoff mark-rushakoff deleted the dockerfile-cleanup branch October 27, 2022 15:54
mark-rushakoff added a commit that referenced this pull request Oct 27, 2022
Discusssion in #3 says that the final image didn't need golang.
mark-rushakoff added a commit that referenced this pull request Oct 27, 2022
Discussion in #3 says that the final image didn't need golang.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants