# Gitea + CI/CD + `tloto-deploy` (nouveau VPS) ## URLs | Service | URL | |---------|-----| | Gitea (temporaire IP) | http://191.215.41.53:3000/ | | Gitea (après DNS) | https://git.tloto.net/ | | Registry local | `127.0.0.1:5000` (non public) | | Tloto HTTP smoke | http://191.215.41.53:9080/ | Credentials admin Gitea : `~/gitea-admin-credentials.txt` sur le VPS. ## Architecture - **Gitea** : dépôt central + Actions. - **act_runner** : CI (build/tests/images) — ne déploie pas la prod directement. - **`tloto-deploy`** : seul mécanisme prod (manuel SSH ou workflow `Deploy` via clé SSH restreinte). - **Commandes historiques** inchangées : `sudo npm run db:migrate`, `sudo npm run phase-b:up:https`. ## Déploiement manuel (SSH) ```bash ssh deploy@191.215.41.53 tloto-deploy --ref main --mode http # après cutover HTTPS : tloto-deploy --ref --mode https tloto-deploy --rollback ``` ## Déploiement manuel (Gitea UI) 1. Repo → Actions → workflow **Deploy** → Run workflow. 2. Renseigner `ref` (SHA/branche) et `mode`. 3. Secrets requis : `DEPLOY_SSH_KEY` (privé `~/gitea-deploy-ssh/id_ed25519`), `DEPLOY_SSH_HOST` (ex. `172.16.0.1`). ## CI (automatique) Push/PR sur `main` / `master` / `develop` → workflow **CI** : 1. Checkout git + `npm ci` + compile backend 2. Build images Docker (job image `ghcr.io/catthehacker/ubuntu:act-22.04` avec CLI Docker) 3. Push vers registry local `172.16.0.1:5000/tloto-*:` 4. **Pas** de mise en prod Le runner est déclaré avec les labels `ubuntu-latest` / `ubuntu-22.04`. Les secrets Actions `DEPLOY_SSH_KEY` et `DEPLOY_SSH_HOST` servent uniquement au workflow **Deploy** manuel. ## pgAdmin (Windows) Voir `~/pgadmin-db-credentials.txt` sur le VPS. Tunnel SSH uniquement — jamais exposer 5432. ```powershell ssh -N -L 5433:127.0.0.1:5432 deploy@191.215.41.53 ``` ## Rollback - Application : `tloto-deploy --rollback` (réactive le `prev_sha`). - PostgreSQL : **pas** de rollback automatique ; dumps dans `/var/lib/tloto/backups/` avant migrate si `schema.sql` a changé. ## Edge HTTPS `git.tloto.net` Quand le DNS A de `git.tloto.net` pointe vers le VPS : ```bash cd ~/edge # placer fullchain.pem + privkey.pem dans certs/ puis décommenter le bloc 443 dans nginx.conf sudo docker compose --profile edge up -d # Mettre à jour ~/gitea/.env : GITEA_ROOT_URL=https://git.tloto.net/ sudo docker compose -f ~/gitea/docker-compose.yml up -d gitea ```