Shrink an Image with a Multi-Stage Build
Labs have no container engine, so nothing is built or started: your files are checked by reading them, the way a reviewer or a CI linter would. docker-compose config (to validate Compose files) and hadolint (a Dockerfile linter) are installed.
The image of the Go service in /home/student/projects/label-printer is 900 MB, because it ships the whole Go toolchain and source code to production.
Rewrite the Dockerfile as a multi-stage build:
build, based on golang:1.23, that compiles a static binary (CGO_ENABLED=0) to /out/label-printergcr.io/distroless/static-debian12 that contains only the binary, copied from the build stage/label-printer as its entrypoint, as a non-root user (distroless provides nonroot, UID 65532)About this machine
Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.
Your machine is ready to start
Create a free account to open a machine and get graded.