Compare commits

...

2 Commits

Author SHA1 Message Date
gitea-actions
1696602abb chore: bump version to v0.1.38
All checks were successful
Auto Tag Develop / tag (push) Successful in 7s
Build & Push Docker Image / build (push) Successful in 22s
2026-05-19 06:38:13 +00:00
Matthieu
cacd8718e5 chore(prod) : ajuster conf prod pour HTTP en reseau local
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
- .env.prod.example : JWT_COOKIE_SECURE=0, CORS_ALLOW_ORIGIN en http
- prompt-rename-prod.md : retirer etape certbot/Let's Encrypt, verifier la resolution locale a la place
- deployment-docker.md : aligner DEFAULT_URI, CORS et JWT_COOKIE_SECURE sur HTTP
2026-05-19 08:38:03 +02:00
4 changed files with 26 additions and 30 deletions

View File

@@ -1,2 +1,2 @@
parameters:
app.version: '0.1.37'
app.version: '0.1.38'

View File

@@ -152,7 +152,7 @@ DATABASE_URL="postgresql://malio:password@host.docker.internal:5432/starseed_pro
JWT_SECRET_KEY=%kernel.project_dir%/config/jwt/private.pem
JWT_PUBLIC_KEY=%kernel.project_dir%/config/jwt/public.pem
JWT_PASSPHRASE=<generer avec: openssl rand -hex 32>
JWT_COOKIE_SECURE=1
JWT_COOKIE_SECURE=0
JWT_COOKIE_SAMESITE=lax
JWT_TOKEN_TTL=86400
JWT_COOKIE_TTL=86400
@@ -161,7 +161,7 @@ JWT_COOKIE_TTL=86400
CORS_ALLOW_ORIGIN='^https?://starseed\.malio-dev\.fr$'
# App
DEFAULT_URI=https://starseed.malio-dev.fr
DEFAULT_URI=http://starseed.malio-dev.fr
```
### 6. Generer les cles JWT

View File

@@ -2,8 +2,9 @@
Copier-coller integralement dans une session Claude lancee **sur le serveur de prod** apres que :
- le push develop + build CI ont publie l'image `gitea.malio.fr/malio-dev/starseed:latest`,
- le DNS `starseed.malio-dev.fr` resout vers ce serveur,
- un certificat Let's Encrypt existe (ou est pret a etre genere) pour `starseed.malio-dev.fr`.
- la resolution reseau local (DNS interne ou `/etc/hosts` des postes clients) pour `starseed.malio-dev.fr` est en place.
> Setup : HTTP en reseau local, pas de TLS. Pas de Let's Encrypt.
---
@@ -11,7 +12,7 @@ Copier-coller integralement dans une session Claude lancee **sur le serveur de p
Tu es sur le serveur de production d'une app Symfony+Nuxt qui s'appelait **Coltura** et qui doit etre renommee en **Starseed**. Le rename cote code est deja fait et merge. Le repo Gitea s'appelle deja `starseed`. L'image `gitea.malio.fr/malio-dev/starseed:latest` est publiee.
Le DNS `starseed.malio-dev.fr` resout vers ce serveur. Le certificat Let's Encrypt pour ce nom de domaine est gere a la main par l'admin (a confirmer avant l'etape nginx).
L'app est servie en **HTTP sur reseau local** (pas de TLS, pas de Let's Encrypt). La resolution `starseed.malio-dev.fr` est faite via DNS interne ou `/etc/hosts` cote postes clients — pas de certificat a gerer.
Objectif : basculer la prod sur le nouveau nom (registry, container, DB, path FS, vhost) **sans perdre les donnees** et avec downtime minimal (mode maintenance pendant la migration).
@@ -30,9 +31,6 @@ ls -la /var/www/starseed/ 2>/dev/null | head -5
# 4. Vhost nginx system
sudo ls -la /etc/nginx/sites-enabled/ | grep -E "coltura|starseed"
# 5. Cert Let's Encrypt
sudo ls /etc/letsencrypt/live/ | grep -E "coltura|starseed"
```
**Apres confirmation de l'etat, executer dans cet ordre, en demandant validation utilisateur AVANT chaque etape destructive (DB drop, rm -rf, certificat) :**
@@ -43,7 +41,7 @@ sudo ls /etc/letsencrypt/live/ | grep -E "coltura|starseed"
cd /var/www/coltura
touch maintenance.on
# Verifier qu'une requete renvoie 503
curl -s -o /dev/null -w "HTTP %{http_code}\n" https://coltura.malio-dev.fr/
curl -s -o /dev/null -w "HTTP %{http_code}\n" http://coltura.malio-dev.fr/
```
Doit renvoyer `503`.
@@ -100,17 +98,18 @@ sudo test -f /var/www/starseed/.env && echo ".env OK"
Editer `/var/www/starseed/.env` :
- `DATABASE_URL` : remplacer `/coltura_prod` -> `/starseed_prod` (et user si renomme a etape 3)
- `CORS_ALLOW_ORIGIN` : remplacer `coltura.malio-dev.fr` -> `starseed.malio-dev.fr`
- `DEFAULT_URI` : `https://starseed.malio-dev.fr`
- `DEFAULT_URI` : `http://starseed.malio-dev.fr`
- `JWT_COOKIE_SECURE` : doit etre `0` (HTTP, pas de TLS) — verifier qu'il l'est deja
Diff attendu :
```diff
- DATABASE_URL="postgresql://malio:xxx@host.docker.internal:5432/coltura_prod?..."
+ DATABASE_URL="postgresql://malio:xxx@host.docker.internal:5432/starseed_prod?..."
- CORS_ALLOW_ORIGIN='^https?://coltura\.malio-dev\.fr$'
+ CORS_ALLOW_ORIGIN='^https?://starseed\.malio-dev\.fr$'
- DEFAULT_URI=https://coltura.malio-dev.fr
+ DEFAULT_URI=https://starseed.malio-dev.fr
- CORS_ALLOW_ORIGIN='^http://coltura\.malio-dev\.fr$'
+ CORS_ALLOW_ORIGIN='^http://starseed\.malio-dev\.fr$'
- DEFAULT_URI=http://coltura.malio-dev.fr
+ DEFAULT_URI=http://starseed.malio-dev.fr
```
### Etape 6 — Stopper et supprimer l'ancien container
@@ -144,9 +143,9 @@ sudo docker compose exec -T -u www-data app php bin/console cache:clear --env=pr
sudo docker compose exec -T -u www-data app php bin/console cache:warmup --env=prod
```
### Etape 9 — Vhost nginx system + certificat
### Etape 9 — Vhost nginx system (HTTP only)
Copier le nouveau vhost (a jour avec `server_name starseed.malio-dev.fr` et `root /var/www/starseed/public`) :
Copier le nouveau vhost (a jour avec `server_name starseed.malio-dev.fr` et `root /var/www/starseed/public`, `listen 80` uniquement) :
```bash
sudo cp /var/www/starseed/infra/prod/nginx-proxy.conf /etc/nginx/sites-available/starseed.conf
@@ -155,14 +154,10 @@ sudo rm -f /etc/nginx/sites-enabled/coltura.conf
sudo nginx -t
```
**Avant de reload nginx**, generer le certificat Let's Encrypt pour le nouveau domaine (l'utilisateur doit confirmer ; certbot peut casser temporairement le vhost actuel pendant la challenge) :
Verifier la resolution reseau local avant reload :
```bash
# Verifier le DNS d'abord
dig +short starseed.malio-dev.fr
# Generer le cert (l'utilisateur valide)
sudo certbot --nginx -d starseed.malio-dev.fr --non-interactive --agree-tos -m matthieu@malio.fr
getent hosts starseed.malio-dev.fr || echo "ATTENTION : starseed.malio-dev.fr ne resout pas localement"
```
Puis :
@@ -176,9 +171,9 @@ sudo systemctl reload nginx
```bash
rm -f /var/www/starseed/maintenance.on
# Tests externes
curl -s -o /dev/null -w "HTTP %{http_code}\n" https://starseed.malio-dev.fr/
curl -s https://starseed.malio-dev.fr/api/version
# Tests externes (HTTP local)
curl -s -o /dev/null -w "HTTP %{http_code}\n" http://starseed.malio-dev.fr/
curl -s http://starseed.malio-dev.fr/api/version
```
`/api/version` doit renvoyer du JSON avec la version courante.
@@ -229,8 +224,8 @@ rm -f /var/www/coltura/maintenance.on
## Regles de comportement pour le Claude prod
- **Ne jamais skipper le backup** (etape 2).
- **Demander confirmation utilisateur** avant : `DROP DATABASE`, `rm -rf`, `certbot`, et avant de lever le mode maintenance final.
- **Demander confirmation utilisateur** avant : `DROP DATABASE`, `rm -rf`, et avant de lever le mode maintenance final.
- **Une seule operation destructive a la fois**, attendre le retour utilisateur entre chaque.
- **Logger systematiquement** la sortie des commandes critiques (pg_dump, docker compose up, certbot).
- **Logger systematiquement** la sortie des commandes critiques (pg_dump, docker compose up, nginx -t / reload).
- **Si une etape echoue**, NE PAS continuer — declencher le rollback.
- **Ne commit rien** sur le repo depuis le serveur prod.

View File

@@ -5,8 +5,9 @@ APP_SECRET=CHANGE_ME_IN_PRODUCTION
DATABASE_URL="postgresql://starseed:CHANGE_ME@host.docker.internal:5432/starseed_prod?serverVersion=16&charset=utf8"
JWT_PASSPHRASE=CHANGE_ME_IN_PRODUCTION
JWT_COOKIE_SECURE=1
# HTTP en reseau local => cookie non secure
JWT_COOKIE_SECURE=0
JWT_TOKEN_TTL=86400
JWT_COOKIE_TTL=86400
CORS_ALLOW_ORIGIN='^https://starseed\.malio-dev\.fr$'
CORS_ALLOW_ORIGIN='^http://starseed\.malio-dev\.fr$'