Problem
Currently, devtools/docker/Dockerfile.frontend uses the golang image as its base image.
This is inconsistent with modern best practices, where services are typically hosted on the minimal scratch image. The current image has an entire operating system and the Go toolchain included, which is unnecessary because only the frontend and its data are copied in. The frontend doesn’t need an entire OS to run.
Suggested solution
- Build cmd/frontend with
CGO_ENABLED=0 to produce a statically linked binary.
- Use
FROM scratch to build the final Docker image.
Links
Related: #39827
Problem
Currently, devtools/docker/Dockerfile.frontend uses the golang image as its base image.
This is inconsistent with modern best practices, where services are typically hosted on the minimal scratch image. The current image has an entire operating system and the Go toolchain included, which is unnecessary because only the frontend and its data are copied in. The frontend doesn’t need an entire OS to run.
Suggested solution
CGO_ENABLED=0to produce a statically linked binary.FROM scratchto build the final Docker image.Links
Related: #39827