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

Use static linking when building Go binaries for Docker image #33

Closed
evanmcclure opened this issue Jun 24, 2020 · 1 comment · Fixed by #34
Closed

Use static linking when building Go binaries for Docker image #33

evanmcclure opened this issue Jun 24, 2020 · 1 comment · Fixed by #34

Comments

@evanmcclure
Copy link
Member

evanmcclure commented Jun 24, 2020

This will create larger binaries. However, the Docker base image can be swapped out for a distroless image such as scratch, which will make the resulting Docker image smaller.

One aspect to consider is whether the CGO versions of dependencies are used, as this can effect how the statically linked binaries are built.

@evanmcclure
Copy link
Member Author

In case you're interested, here's an excellent, recent article about building Go binaries statically. It includes useful info about CGO and cross-compilation, too.

https://golangnews.org/2020/04/statically-compiling-go-programs-2/

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 a pull request may close this issue.

1 participant