games_app/docs/GITEA-CICD.md
Your Name 156d37ea26
All checks were successful
CI / test-and-build (push) Successful in 36s
Fix CI runner Docker image and deploy SSH ForceCommand wrapper
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-17 20:38:57 +02:00

72 lines
2.4 KiB
Markdown

# 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 <sha> --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-*:<sha12>`
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
```