Suggested Dockerfile improvements
Improvements:
- separate out
go mod download
to utilise build cache. - explicit in source repo for
golang
builder image (other container runtimes may not default todocker.io
). - switch to UID 1000 to help reduce privileges of the running binary in the container to reduce potential container escape attack surface.
-
-w -s
in thego build
step to strip out debugging symbols to reduce binary size. - default to main as VERSION.
- shallow git clone with
--depth=1
since we don't need a full git history to perform a build. - golang 1.17 rather than 1.15, some improvements in runtime performance and binary size.