Deployment and production operations
6 modules · 7 lessons · 11 exercises · 18 available now
Week 7 overview
- Module 1 Production containers and CI
- 7.1 Multi-stage Dockerfiles for GoMulti-stage build, Distroless image, Static Go binary, CGO_ENABLED=0, Non-root container, Compose restart policy, Compose environment file and secrets
- 7.2 Production container stack
- 7.3 Gated CI image publishingContainer registry, GHCR, Image tag by commit SHA, Test-gated image build, Environment secrets in GitHub Actions
- 7.4 Backend CI workflow
- Module 2 Single-server production deployment
- 7.5 HTTPS health and migration gatesReverse proxy, Automatic HTTPS, Liveness probe, Readiness probe, Migration job, Logical backup, Restore test
- 7.6 Production HTTPS Compose stack
- 7.7 Nightly mysqldump and one restore test
- Module 3 Production app testing
- 7.8 EAS preview build profilesEAS build profile, APK and sideloading, Bug triage
- 7.9 Android preview APK
- 7.10 Seed the Real Canteen and Operating Accounts
- 7.11 Collect bugs for 4 days, fix the top 5, ship again
- Module 4 Order RPC interface
- 7.12 Protobuf contracts in GoProtocol Buffers, gRPC, Buf lint and code generation, gRPC status codes, gRPC metadata, gRPC interceptors, Server-streaming RPC, bufconn in-memory gRPC testing
- 7.13 gRPC order service
- Module 5 Single-server capacity
- 7.14 Single-server capacity estimationCapacity headroom, Recovery time objective, Deploy downtime budget
- Module 6 Release safety extensions
- 7.15 Release checks and gRPC recovery (optional)Secret scanning, Rollback by image tag, gRPC recovery interceptor, gRPC deadline
- 7.16 Filesystem secret scanner (optional)
- 7.17 gRPC resilience interceptors (optional)
- 7.18 Release rollback planner (optional)
Weekly learning objectives
Week 6 measured backend performance. This week you package the API and worker for production, deploy the system on one server, put an Android preview build in testers' hands, and expose the order domain over gRPC.
- Production containers and CI: Build multi-stage distroless images for the API and worker, then test and publish commit-tagged images through CI.
- Single-server production deployment: Run the production stack behind Caddy with HTTPS, dependency-aware health checks, migration gating and verified database backups.
- Production app testing: Build a preview APK, seed a real canteen and operating accounts, then use tester reports to prioritize fixes.
- Order RPC interface: Add a gRPC order service beside HTTP, sharing the existing order domain and streaming order updates to RPC clients.
- Single-server capacity: Model the production Compose stack to estimate traffic, resource limits and recovery costs on one server.
- Release safety extensions: Add optional secret-scanning, gRPC recovery and deadline interceptors, and image rollback planning.
System architecture and changes
The system moves from your laptop to a production server. Caddy terminates TLS and acts as the reverse proxy. Docker Compose manages the services, named volumes and restart policies. GitHub Actions tests the backend and publishes commit-SHA images to GHCR.
The order domain now supports HTTP and gRPC through the same store and JWT signer. The gRPC service exposes order operations and streams order updates without duplicating the existing business logic.
How to complete the coursework
Start with Production containers and CI, then move to Single-server production deployment. Work on Production app testing as soon as you have a preview build, so tester feedback can guide your fixes. Continue with Order RPC interface and Single-server capacity.
Release safety extensions are optional and independent of the required Week 7 work.
Run make test W=W7 from backend/ to execute every graded Week 7 test, including the optional extensions.
Modules
Module 1: Production containers and CI
4 itemsYou build production images for the API and worker, then test and publish commit-tagged images through CI.
7.1Multi-stage Dockerfiles for Go
You can separate Go compilation from the distroless runtime so the API and worker images contain only their executables.
Open lesson →7.2Production container stack
You build the production container stack for the Go API and worker, with distroless images and Compose services for MySQL, Redis, Redpanda, and Caddy. Both application services wait for MySQL's healthcheck, and Compose receives credentials through environment interpolation.
Open exercise →7.3Gated CI image publishing
You can use service containers to test against MySQL and Redis, then gate GHCR publishing on passing checks so the next exercise can deploy identified images.
Open lesson →7.4Backend CI workflow
You build the backend CI workflow that tests against MySQL and Redis, then publishes the API and worker images to GHCR with the commit SHA.
Open exercise →
Module 2: Single-server production deployment
3 itemsYou build a single-server deployment with HTTPS, dependency-aware health checks, migration gating, and a database backup verified by a restore test.
7.5HTTPS health and migration gates
You can route API traffic through Caddy and distinguish liveness from readiness, so the production stack waits for migrations before serving requests.
Open lesson →7.6Production HTTPS Compose stack
You build the production Compose stack that serves the API through Caddy over HTTPS and waits for a successful migration before startup.
Open exercise →7.7Nightly mysqldump and one restore test
You build a nightly MySQL backup service that creates timestamped compressed dumps of
Open exercise →zomatoand verifies recovery in an isolatedrestore_testdatabase. The service retains the newest configured backups and preserves the latest successful dump when a backup fails.
Module 3: Production app testing
4 itemsYou build a preview APK, seed a real canteen and operating accounts, then use tester reports to prioritize fixes.
7.8EAS preview build profiles
You can configure an EAS preview profile that embeds a reachable HTTPS API URL and produces an internally distributed APK for real-device testing.
Open lesson →7.9Android preview APK
You build an Android preview APK from the Expo app using an EAS profile and a validated API URL. The preview profile produces an internally distributed APK with an HTTPS API endpoint.
Open exercise →7.10Seed the Real Canteen and Operating Accounts
You build a deterministic canteen dataset containing a real location, menu, opening hours and operating users. Its opening windows integrate with the existing Week 2 hours index.
Open exercise →7.11Collect bugs for 4 days, fix the top 5, ship again
You build a Go triage library that ranks reported issues, validates deliberate exclusions, selects fixes and generates a Markdown release report. Use the ranking to fix the five highest-priority bugs and distribute an updated Android preview build.
Open exercise →
Module 4: Order RPC interface
2 itemsYou build a gRPC order service beside HTTP, reusing the existing order domain and streaming order updates to RPC clients.
7.12Protobuf contracts in Go
You can define an RPC contract and trace how generated Go code connects it to a server, preparing the existing order domain for gRPC.
Open lesson →7.13gRPC order service
You build a gRPC order service that accepts protobuf requests and returns order responses or a stream of order events. Protected calls reuse the JWT signer, and PlaceOrder requires idempotency metadata.
Open exercise →
Module 5: Single-server capacity
1 itemsYou build a capacity model for the production compose stack so you can judge traffic, resource limits and recovery costs on one server.
7.14Single-server capacity estimation
You can estimate whether the production stack fits on one VPS and identify which measurements must validate the plan before launch.
Open lesson →
Module 6: Release safety extensions
4 itemsYou add optional release-safety and gRPC resilience tools to detect exposed credentials, contain RPC failures, and plan image rollbacks.
7.15Release checks and gRPC recovery
You can gate releases with secret checks and image rollback, then contain gRPC failures with interceptors and deadlines before building the filesystem scanner.
Open lesson →7.16Filesystem secret scanner
You build a Go filesystem scanner that walks an
Open exercise →fs.FSand returns sorted findings containing only file paths, line numbers, and rule names.7.17gRPC resilience interceptors
You build three gRPC interceptors that wrap unary and streaming handlers, recover panics as generic Internal errors, and enforce unary deadlines without extending client deadlines.
Open exercise →7.18Release rollback planner
You build a Go release rollback planner that validates image references, pins a selected Compose service to a commit-SHA tag, and returns the previous distinct deployed release.
Open exercise →
Completion checklist
What should be true at the end of the week.
make test W=W7passes every graded Week 7 test.- Both production Dockerfiles, the build context exclusions,
.env.exampleandcompose.prod.ymlpass their configuration checks. .github/workflows/backend.ymlpasses workflow checks for testing, linting, race tests and commit-SHA image publishing.- Caddy,
/healthz,/readyzand the migration service satisfy the deployment and health-check tests. - Backup and restore scripts pass their tests for consistent dumps, retention, failure cleanup and isolated restoration.
- The EAS preview configuration, canteen seed, triage planner, gRPC service and optional extensions pass their respective tests.
Week requirements
Rules every piece of code this week must follow.
- Build the API and worker as static binaries using Go build stages and distroless non-root runtime stages. Keep secrets and Git history out of the build context and image layers.
- Define every production service in
compose.prod.ymlwithrestart: unless-stopped. Use named volumes for stateful services, interpolate passwords from environment variables, and make the API and worker wait for healthy MySQL. - Run CI on pushes and pull requests with MySQL and Redis health-checked services. Pin every action, lint and run race tests, then publish both GHCR images with the commit SHA only on
mainafter tests pass. - Publish only Caddy to the internet. Keep
/healthzas dependency-free200JSON, make/readyzrun concurrent checks with a timeout and return503naming every failing dependency without leaking error text. Run migrations as a one-shot service before the API. - Take consistent timestamped gzip dumps of the
zomatodatabase, maintain retention without deleting files the backup did not create, and restore into a fresh database without touching the live database. - Keep the EAS preview configuration aligned with the API URL. Seed deterministic canteen data with at least eight unique menu items in at least three categories, valid opening windows, whole-rupee prices stored in paise, distinct operating-account emails and no passwords. Preserve restaurant IDs on slots.
- Rank triage issues by severity and distinct reporters, break ties by issue number, and reject invalid plans. The gRPC service must preserve order idempotency, authentication, error-to-status mapping and order streaming. Optional extensions must satisfy their secret-scanning, recovery/deadline and release-rollback contracts.