History
How the infrastructure reached its current state. Each step quotes the commit that introduced it.
The steps
| Date | Change | Commit | Why |
|---|---|---|---|
| 28 Oct. | First API Dockerfile.dev and Dockerfile.prod | ci:added the dockerfile.dev file | start containerising |
| 2 Nov. | api/, web/, infra/, docs/ tree and root .gitignore | chore: add base project structure and root .gitignore | set up the monorepo |
| 2 Nov. | mobile/ folder removed | chore: remove mobile directory | mobile comes in part 801 |
| 2 Nov. | Products API + api/.gitlab-ci.yml | feat(api): add product API and CI pipeline | the first tested sample |
| 9 Nov. | gitlab-runner role | feat(ansible): add GitLab Runner role | install runners reproducibly |
| 9 Nov. | Datadog and the base role removed | chore(infra): remove Datadog and base role | focus on deployment |
| 9 Nov. | Next.js web sample, Dockerfiles, web:* jobs | feat(web): add Next.js sample, Dockerfiles and CI jobs | the second sample |
| 10 Nov. | One VM per environment, one Traefik per machine | chore(ansible): split servers into dev and prod machines | isolate prod from dev |
| 10 Nov. | Runner tokens in Ansible Vault | chore(ansible): add encrypted Vault with the runner token | no secret in plain text |
| 13 Nov. | Root .gitlab-ci.yml with include | ci: add root pipeline with runner check and API and web jobs | GitLab only reads the root file: the api:* and web:* jobs did not run before |
| 14 Nov. | Swarm in prod, Compose in dev | feat(infra): deploy with Docker Swarm in prod and Compose in dev | zero downtime without scripted blue/green |
| 14 Nov. | A shell deploy runner on each server | feat(ansible): enable Swarm and add a deploy runner on each server | deploy without an SSH key |
| 14 Nov. | deploy-dev and deploy-prod jobs | ci: deploy dev and prod automatically | deployment without intervention |
| 14-15 Nov. | api:build and web:build on every push to develop and main | ci(api): build the API image on every develop and main merge, ci(web): … | see below |
| 15 Nov. | chown appuser /app in the API prod image | fix(api): let appuser write the static files in the prod image | the prod API crashed at startup |
| 16 Nov. | Add form, delete, new web style | feat(web): restyle the page and manage products from it | a more representative sample |
Building every time
At first, api:build and web:build only ran if their folder had changed. But deploy-prod runs both images with the commit SHA. A commit that only touched the web would therefore have had no api:<sha> image, and the deployment would have failed with manifest unknown.
The fix: build both images on every push to develop and main. It takes a bit longer, but every main commit always has its two images.
What was planned and changed
| Planned in the task split | Done in the end | Page |
|---|---|---|
| A single VPS for dev and prod | two VMs | Environments |
| Blue/green behind Traefik | Swarm start-first + rollback | Zero-downtime deployment |
| Deployment over SSH from the pipeline | a shell runner on each server | Runners |
| SSH hardening and fail2ban in Ansible | UFW firewall only | Limits |
| gitleaks job | not yet | Limits |
| Datadog monitoring | removed | Technical choices |