Skip to content

Variables, versions, files ​

Project CI/CD variables ​

To set in Settings → CI/CD → Variables, as Masked and Protected.

VariableUsed byRole
POSTGRES_PASSWORDdeploy-dev, deploy-prodPostgreSQL password, given to db and api
DJANGO_SECRET_KEYdeploy-dev, deploy-prodDjango secret key

Variables provided by GitLab ​

VariableUsed by
CI_COMMIT_BRANCHworkflow, rules of every job
CI_COMMIT_SHORT_SHAimage tag, docker-compose.prod.yml, deploy-prod check
CI_REGISTRY, CI_REGISTRY_IMAGE*:build, deploy-prod
CI_REGISTRY_USER, CI_REGISTRY_PASSWORDdocker login in *:build and deploy-prod

Ansible variables ​

VariableFileRole
ansible_usergroup_vars/all/main.ymlSSH user
ansible_ssh_private_key_filegroup_vars/all/main.ymlSSH key
app_rootgroup_vars/all/main.yml/opt/trinity, where Traefik lives on the servers
gitlab_runner_namegroup_vars/all/main.ymlCI runner name: trinity-dev-runner
gitlab_runner_tokengroup_vars/all/vault.yml (encrypted)CI runner token
deploy_runner_tokensgroup_vars/all/vault.yml (encrypted)deploy runner tokens, per machine

Application variables are in each part's reference: API, web.

Versions ​

Building blockVersionFile
Traefikv3.6infra/traefik/docker-compose.yml
PostgreSQL17, Alpineinfra/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 imagealpine:3.21gitlab-runner role
Node.js22, Alpineweb/Dockerfile.*
Python3.11, slimapi/Dockerfile.*
Docker Engine, Compose, GitLab Runnerlatest version from the official APT repositoriesdocker, gitlab-runner roles
VM operating systemUbuntuinventory.ini

Ports ​

PortWhereOpen to the Internet
22SSHyes
80Traefik, redirects to 443 and serves the Let's Encrypt challengeyes
443Traefik, HTTPSyes
3000web, in the trinity networkno
8000api, in the trinity networkno
5432PostgreSQL, in the internal networkno

Names ​

NameWhat it is
trinitythe Compose project in dev, the Swarm stack in prod, and the overlay network shared with Traefik
trinity_api, trinity_webthe containers (dev) or services (prod) targeted by Traefik
trinity-traefikthe Traefik container
/opt/trinity/traefik/Traefik's configuration on each server
/etc/gitlab-runner/config.tomlthe 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"