Trinity
From merge to prod, with no manual step and no downtime.
Part 1 · Elias
Two gestures to deploy
“There should be two tasks for a human being to perform to deploy software: to pick the version and environment and to press the deploy button.”
David Farley, Continuous Delivery, quoted by the subject
the commit
the branch
the merge

Part 2 · The whole team
Tools we master, time for DevOps
| Need | Choice | Why |
|---|---|---|
| API | Django + DRF, Gunicorn | Patrice's strength, a fast CRUD |
| Web | Next.js, server rendering | Jean-Baptiste's strength |
| Database | PostgreSQL 17 | standard, official image |
| CI/CD | GitLab CI, our own runners | asked by the subject, jobs on our VMs |
| Containers | Compose in dev, Swarm in prod | zero downtime and rollback, no script |
| Entry | Traefik + Let's Encrypt | automatic HTTPS, one route per file |
| Servers | 2 Google Cloud VMs + Ansible | dev isolated from prod, replayable config |
Part 3 · Elias
A monorepo, protected branches
feature/*
lint + tests
develop
deploy → dev
main
deploy → prod
Part 3 · Elias
Two VMs, two ways to run
GITLAB.COM
→ GitHub mirror
→ Datadog
The runners call it: nothing comes into the VMs
DEV · DEVELOP · COMPOSE
Images built on the spot
Update: short outage
PROD · MAIN · SWARM
Images from the registry: api:<sha>
Update: no downtime, auto rollback
Part 4 · Patrice
Django REST and PostgreSQL
Structure
productsapp: model, serializer, ViewSet/api/products/as a CRUD/healthfor the probes
Dev → prod
- Dev:
runserver, one stage - Prod: two stages, Gunicorn
appusernon-root, health check- migrate + collectstatic at startup
Tests
- 7 pytest-django tests
- JUnit report and coverage in the MR
- flake8 at lint
Part 5 · Jean-Baptiste
Next.js, server-side rendering
Structure
- Page rendered on the server
- Add and delete through Server Actions
- The browser never talks to the API
Dev → prod
- Dev:
next dev - Prod: three stages, standalone build
nextjsnon-root, health check
Tests
- 18 Jest and Testing Library tests
- JUnit report and coverage
- ESLint at lint
Part 6 · Elias
Four stages, triggered by the branch
push
any
branch
lint
api:lint
web:lint
test
api:test
web:test
build
api, web,
docs
deploy
deploy-dev
deploy-prod
| Push to | lint and test | build | deployment |
|---|---|---|---|
feature/* | if the folder changed | no | no |
develop | if the folder changed | yes | dev |
main | if the folder changed | yes | prod |
Each deployment checks itself: curl on /health, and in prod the 3 services must run the commit's image.
Part 7 · Elias
Three runners, on our two VMs
| Runner | Machine | Executor | Tag | Runs |
|---|---|---|---|---|
| trinity-dev-runner | dev | docker, privileged | none | lint, tests, builds |
| trinity-dev-deploy | dev | shell | dev | deploy-dev |
| trinity-prod-deploy | prod | shell | prod | deploy-prod |
Installed by Ansible, tokens in the Vault. They call GitLab: no deployment SSH key. GitLab shared runners disabled.
Part 8 · Elias
No secret in the repository
GitLab variables
Masked, protected, hidden, one value per environment
Ansible Vault
Runner tokens encrypted, password outside Git
No deployment key
The runners call GitLab, nothing comes in
Containers
Non-root in prod, only Traefik publishes ports
Network
GCP firewall + UFW: 22, 80, 443. SSH by key
HTTPS everywhere
Let's Encrypt, port 80 redirects to 443
Part 9 · Elias, with the team
From commit to prod, live
A merge request to develop: lint, tests, report
The merge into develop: deployment to dev
The request counter running against prod
The merge into main: prod changes, 0 errors
The rollback: Environments › prod › Re-deploy
The pipeline and its durations in Datadog
0
errors in 1,268 requests during a real prod release
Part 10 · Elias
Load balancer and monitoring

Load balancer: two instances of the API and the web, Swarm spreads the requests
Monitoring: every pipeline and every job in Datadog, no agent
Also: the docs published by the pipeline, the GitHub mirror
Log persistence: not done
Thank you
Any questions?