-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Docker optimizations #245
base: master
Are you sure you want to change the base?
Docker optimizations #245
Conversation
- Use the official golang:alpine image for the build. (see also mailhog#191). - Build and install MailHog from the current repository instead of retrieving it from GitHub. - Statically compile MailHog, so it can be installed without any dependencies. - Disable symbol table and DWARF generation for a smaller binary size. - Build the final Docker image from scratch, adding only the MailHog binary and ca-certificates.
Can you please get this one through?! |
This is build result on my computer
|
COPY --from=build /go/bin/MailHog /bin/ | ||
# Avoid permission issues with host mounts by assigning a user/group with | ||
# uid/gid 1000 (usually the ID of the first user account on GNU/Linux): | ||
USER 1000:1000 | ||
ENTRYPOINT ["MailHog"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double checking; should this be either /bin/Mailhog
, or should the COPY
put the binary at the root (/
)?
(didn't test it, perhaps the default PATH
takes care of that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I just ran some test with this branch. Works both with and without the absolute path.
FROM scratch | ||
# ca-certificates are required for the "release message" feature: | ||
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ | ||
COPY --from=build /go/bin/MailHog /bin/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LICENSE.md should probably also be copied in the final image (as this is distributing the software, which (I think) requires the license to be included)
* | ||
.git | ||
docs | ||
*.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would prevent the license to be copied to the image; perhaps a good idea to rename LICENSE.md
to just LICENSE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or !LICENSE.md
Instead of using more information about the distroless images is available on https://github.com/GoogleContainerTools/distroless |
I was able to build this for ARM64 too using these commands (assumes
Can we please get this merged and official builds (including ARM64) released? |
Inspired by this PR, we have made this (which we use in daily basis). Here is the Dockerfile: https://github.com/druidfi/docker-images/blob/main/misc/mailhog/Dockerfile |
Now that #191 got merged, #205 does not apply anymore. This is a rebase of that commit so that it applies cleanly.
I think this is important so that we can slim the delivered image!