-
Notifications
You must be signed in to change notification settings - Fork 9
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
feat(docker): add Dockerfile #25
Conversation
There are a few ways to complete issue #10.
I recommend References: |
I would probably use 2 dockerfile's... One named The difference would be that inside the In the generic |
I will add the build flags to the already provided I'd like to add a method to automate docker build during local development. That could be introducing a I defer to the style of this project or can defer that automation to a separate offered pull request. |
@@ -0,0 +1,13 @@ | |||
FROM golang:1.11 as build |
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.
I normally use the image tag that is as precise as possible ie in this case1.11.2-alpine3.8
. I could live with 1.11-alpine3.8
so fixes are included when rerunning docker builds.
WORKDIR / | ||
COPY . / | ||
ENV CGO_ENABLED 0 | ||
RUN go build -tags 'static' -ldflags '-extldflags "-static"' . |
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.
I would like to (re)check what flags are actually nice to use (and what there use actually means). Here I have added a lot of flags https://github.com/Ilyes512/kubia/blob/master/Dockerfile#L16 Adding -s -w
removes some debugging things that would reduce the image size (not that it really matters).
FROM scratch | ||
LABEL maintainer="https://github.com/Ilyes512/boilr" | ||
|
||
COPY --from=build /boilr / |
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.
Maybe also add these lines https://github.com/Ilyes512/kubia/blob/master/Dockerfile#L22-L24 It copies ssl certs (at this point it might not be needed cause we are not running a server), but adding /etc/passwd
might be nice to add since os/user
uses it as a fallback when building the app without cgo enabled.
I know that cobra (and maybe boilr as well - haven't checked it) use https://github.com/mitchellh/go-homedir at the moment, but that package can be replaced with os/user
(the fallback was added in a later golang version).
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.
There is a build tag for static build with osuser. I'll find it.
After playing with goreleaser I'm going to pass on a I will find the full set of build tags required and tighten the FROM pin. |
Than I will configure Docker hub auto-builds feature so the images will be available on the public registry. Travis for github releases and home brew. Docker hub for the registry. |
This should be added to goreleaser as well. https://goreleaser.com/customization/#Docker
Begins work on issue #10
This change is