lab(lab6): Dockerize QuickNotes β multi-stage + compose + hardening#1201
Open
GrandAdmiralBee wants to merge 5 commits into
Open
lab(lab6): Dockerize QuickNotes β multi-stage + compose + hardening#1201GrandAdmiralBee wants to merge 5 commits into
GrandAdmiralBee wants to merge 5 commits into
Conversation
Signed-off-by: GrandAdmiralBee <karim.abdulkin@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
Lab 6 submission β multi-stage Dockerfile for QuickNotes (β€25 MB target, lands 14.6 MB), distroless-static-nonroot runtime, compose with named-volume persistence + healthcheck, and all 6 hardening defaults applied + Trivy before/after.
Changes
app/Dockerfileβ multi-stage:golang:1.24.13-alpinebuilder βgcr.io/distroless/static-debian12:nonrootruntime.CGO_ENABLED=0,-trimpath -ldflags='-s -w', deps-before-source layer order,/dataprecreated nonroot for self-sufficientdocker run.app/cmd/healthcheck/main.goβ tiny static Go binary (~20 LoC, no deps) that hits/healthand exits 0/1. Solves the "distroless has no shell" healthcheck problem from inside the image.compose.yamlβ servicequicknoteswith named volumequicknotes-data:/data, healthcheck via["CMD", "/healthcheck"], env defaults,restart: unless-stopped, port127.0.0.1:8080:8080(loopback), plus all 6 hardening defaults:user 65532:65532,read_only: true+tmpfs /tmp,cap_drop: [ALL],security_opt: [no-new-privileges:true].submissions/lab6.mdβ Dockerfile+compose paste, image inspect, smoketest, persistence cycle (PRESENT-1 β PRESENT-2 β GONE), all 7 design questions answered, 5 per-default verification commands captured, Trivy before/after table showing the supply-chain story of pinning vs auto-bump.Testing
docker buildβ final image 14.6 MB (under 25 MB cap).docker run --name qn-smoketest -p 18080:8080 quicknotes:lab6+curl :18080/healthβ{"notes":4,"status":"ok"}.docker compose up --build -dβ healthy after first interval; POST/GET/down/up/down -v cycle verified.shnot found (both forms), cap_drop expanded list, ReadonlyRootfs=true (+ Alpine sidecar proof), SecurityOpt=[no-new-privileges].Checklist
app/Dockerfile,compose.yaml,submissions/lab6.mdall present