Capstone: Containerize, Wire CI, and Expose the gRPC Endpoint
Project Brief
Time to ship the thing. Last lesson you learned to measure before you optimize: benchmark with ReportAllocs, capture a profile, follow flat cost, change one thing, re-measure. The capstone takes that measured service and puts it in front of real users, or at least in front of a CI pipeline that pretends to be real users.
The goal is three deliverables that prove the service is deployable:
- A small, static Docker image built from a multi-stage
Dockerfile. - A CI pipeline that runs
go vet, race-enabled tests, and a build on every push. - A verified gRPC call against the running containerized service.
Why it matters: none of these steps are glamorous, but each one catches a different class of bug. The image catches "works on my machine". CI catches "works on my machine at 3pm on Tuesday". The gRPC call catches the wiring mistake you will absolutely make, where the HTTP server listens on the right port and the gRPC server listens on nothing at all.
[!NOTE] This is a capstone, so most of the work is assembling pieces you already own: the gRPC service definition and server from 3.1, the HTTP handlers and graceful shutdown from Module 2, and the profiling habits from 3.2. No new libraries are strictly required.
Requirements
Spec
| Area | Requirement |
|---|---|
| Image | Multi-stage build, final stage based on a minimal base, binary statically linked, image runs as a non-root user |
| Ports | HTTP on 8080, gRPC on 50051, both configurable by env var |
| Health | /healthz returns 200 when both listeners are accepting |
| CI | Runs go vet ./..., go test -race ./..., and go build ./... |
| CI artifact | Build step produces the binary (or the image) and fails loudly on any warning |
| gRPC verification | A client call returns the expected response from the container |
| Shutdown | SIGTERM drains both servers within a bounded timeout |
Environment variables to read at startup, with sane defaults:
This lesson is part of the paid section. Sign in and purchase the course to view the full content. Sign in