CI checks and immutable builds
Use independent syntax and behavior gates
Continuous integration (CI) checks a proposed change before it is promoted. The syntax gate runs the intended binary with the complete configuration and its includes in a disposable prefix. nginx -t checks configuration and tries to open referenced files; it does not establish that a backend is ready or that authorization is correct. The lab uses a generated file and no external includes; run the command from the lab directory after rendering. Use an approved isolated environment, verify nginx -v, and match the production package build and modules before treating results as representative. nginx -T also dumps configuration, so restrict output and never run it on unknown or secret-bearing configuration.
python3 render.py a > nginx.confnginx -vnginx -t -p "$PWD/" -c "$PWD/nginx.conf"Test the behavior that matters
After syntax validation, an authorized isolated integration environment should start the candidate and issue a few bounded requests. Check body, status, headers and denied routes, not just a successful connection. For release A the marker endpoint should return release-a with 200, and an unknown route should return 404. The table below describes the expected assertions, not observed live results. A syntax-valid configuration returning the wrong marker fails release verification. Include proxy routing, identity and cache isolation tests when the release touches those policies.
GET /health -> 200, body readyGET /release -> 200, body release-aGET /missing -> 404GET /private -> 404All requests: lab loopback only; no external trafficPromote the exact tested artifact
An immutable release is an artifact that is not edited in place after approval. Build an image with a reviewed base digest, copy the approved configuration, and identify the resulting image by its own digest. A tag is convenient but can be reassigned. Rebuilding separately for production can change dependencies even when the source commit is identical. This is a Dockerfile fragment with a required, operator-supplied approved digest reference; do not build it with an unreviewed base. Docker is not used by the local lab. An image digest does not cover mutable mounted configuration or secret contents, so track their versions separately.
ARG BASE_IMAGEFROM ${BASE_IMAGE}COPY nginx.conf /etc/nginx/nginx.confModel a release gate before approval
The example models policy rather than an actual CI vendor workflow. A failed gate stops promotion; an absent result is not success. Untrusted changes must not run with deployment credentials, registry write access or privileged runners. Store test artifacts with bounded retention, redact sensitive data, and require a separate deployment approval tied to the exact artifact. The mock pipeline fixture uses this principle to decide whether a release is eligible; it never deploys anything.
review -> render -> syntax -> behavior -> artifact verificationany failed or absent gate -> HOLDall pass -> await deployment approvalapproved artifact -> staged rollout -> verify or rollbackApply what you learned
Practice: A candidate passes nginx -t but returns 200 for a route that must be denied. Design the release decision and list the independent gates. The manual exercise and quiz are staged separately. Related references and the next lesson are listed in the chapter authored map.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
CI checks and immutable builds
Assess configuration release and verification reasoning.
A syntax check passes but denied route returns 200. What next?
Which binary should CI test?
Why avoid uploading unrestricted nginx -T output?
Which artifact should production receive?
A required test result is missing. What does the mock gate do?