Variables, versions, files
Project CI/CD variables
To set in Settings → CI/CD → Variables, as Masked and Protected.
| Variable | Used by | Role |
|---|---|---|
POSTGRES_PASSWORD | deploy-dev, deploy-prod | PostgreSQL password, given to db and api |
DJANGO_SECRET_KEY | deploy-dev, deploy-prod | Django secret key |
Variables provided by GitLab
| Variable | Used by |
|---|---|
CI_COMMIT_BRANCH | workflow, rules of every job |
CI_COMMIT_SHORT_SHA | image tag, docker-compose.prod.yml, deploy-prod check |
CI_REGISTRY, CI_REGISTRY_IMAGE | *:build, deploy-prod |
CI_REGISTRY_USER, CI_REGISTRY_PASSWORD | docker login in *:build and deploy-prod |
Ansible variables
| Variable | File | Role |
|---|---|---|
ansible_user | group_vars/all/main.yml | SSH user |
ansible_ssh_private_key_file | group_vars/all/main.yml | SSH key |
app_root | group_vars/all/main.yml | /opt/trinity, where Traefik lives on the servers |
gitlab_runner_name | group_vars/all/main.yml | CI runner name: trinity-dev-runner |
gitlab_runner_token | group_vars/all/vault.yml (encrypted) | CI runner token |
deploy_runner_tokens | group_vars/all/vault.yml (encrypted) | deploy runner tokens, per machine |
Application variables are in each part's reference: API, web.
Versions
| Building block | Version | File |
|---|---|---|
| Traefik | v3.6 | infra/traefik/docker-compose.yml |
| PostgreSQL | 17, Alpine | infra/docker-compose.*.yml |
| Docker (build jobs) | 27.5.1 (docker:27.5.1-cli + docker:27.5.1-dind) | api/.gitlab-ci.yml, web/.gitlab-ci.yml |
| CI runner default image | alpine:3.21 | gitlab-runner role |
| Node.js | 22, Alpine | web/Dockerfile.* |
| Python | 3.11, slim | api/Dockerfile.* |
| Docker Engine, Compose, GitLab Runner | latest version from the official APT repositories | docker, gitlab-runner roles |
| VM operating system | Ubuntu | inventory.ini |
Ports
| Port | Where | Open to the Internet |
|---|---|---|
| 22 | SSH | yes |
| 80 | Traefik, redirects to 443 and serves the Let's Encrypt challenge | yes |
| 443 | Traefik, HTTPS | yes |
| 3000 | web, in the trinity network | no |
| 8000 | api, in the trinity network | no |
| 5432 | PostgreSQL, in the internal network | no |
Names
| Name | What it is |
|---|---|
trinity | the Compose project in dev, the Swarm stack in prod, and the overlay network shared with Traefik |
trinity_api, trinity_web | the containers (dev) or services (prod) targeted by Traefik |
trinity-traefik | the Traefik container |
/opt/trinity/traefik/ | Traefik's configuration on each server |
/etc/gitlab-runner/config.toml | the runners' configuration on each server |
The root pipeline
yml
stages:
- lint
- test
- build
- deploy
workflow:
rules:
- if: $CI_COMMIT_BRANCH
include:
- local: api/.gitlab-ci.yml
- local: web/.gitlab-ci.yml
- local: docs/.gitlab-ci.yml
deploy-dev:
stage: deploy
tags:
- dev
environment:
name: dev
url: https://dev.trinity.jostud.com
script:
- docker compose -p trinity -f infra/docker-compose.dev.yml up -d --build
- curl -fsS --retry 20 --retry-delay 3 --retry-all-errors https://api.dev.trinity.jostud.com/health
- curl -fsS --retry 20 --retry-delay 3 --retry-all-errors https://dev.trinity.jostud.com/api/health
rules:
- if: $CI_COMMIT_BRANCH == "develop"
deploy-prod:
stage: deploy
tags:
- prod
environment:
name: prod
url: https://trinity.jostud.com
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY"
script:
- docker stack deploy --detach=false --with-registry-auth -c infra/docker-compose.prod.yml trinity
- test "$(docker service ls --format '{{.Image}}' | grep -c "$CI_COMMIT_SHORT_SHA")" = 3
- curl -fsS https://api.trinity.jostud.com/health
- curl -fsS https://trinity.jostud.com/api/health
- curl -fsS -o /dev/null https://docs.trinity.jostud.com/
after_script:
- docker logout "$CI_REGISTRY"
rules:
- if: $CI_COMMIT_BRANCH == "main"