|
|
|
@@ -2,8 +2,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
Copier-coller integralement dans une session Claude lancee **sur le serveur de prod** apres que :
|
|
|
|
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 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,
|
|
|
|
- la resolution reseau local (DNS interne ou `/etc/hosts` des postes clients) pour `starseed.malio-dev.fr` est en place.
|
|
|
|
- un certificat Let's Encrypt existe (ou est pret a etre genere) pour `starseed.malio-dev.fr`.
|
|
|
|
|
|
|
|
|
|
|
|
> 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.
|
|
|
|
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).
|
|
|
|
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
|
|
|
|
# 4. Vhost nginx system
|
|
|
|
sudo ls -la /etc/nginx/sites-enabled/ | grep -E "coltura|starseed"
|
|
|
|
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) :**
|
|
|
|
**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
|
|
|
|
cd /var/www/coltura
|
|
|
|
touch maintenance.on
|
|
|
|
touch maintenance.on
|
|
|
|
# Verifier qu'une requete renvoie 503
|
|
|
|
# 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`.
|
|
|
|
Doit renvoyer `503`.
|
|
|
|
@@ -100,17 +98,18 @@ sudo test -f /var/www/starseed/.env && echo ".env OK"
|
|
|
|
Editer `/var/www/starseed/.env` :
|
|
|
|
Editer `/var/www/starseed/.env` :
|
|
|
|
- `DATABASE_URL` : remplacer `/coltura_prod` -> `/starseed_prod` (et user si renomme a etape 3)
|
|
|
|
- `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`
|
|
|
|
- `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 attendu :
|
|
|
|
|
|
|
|
|
|
|
|
```diff
|
|
|
|
```diff
|
|
|
|
- DATABASE_URL="postgresql://malio:xxx@host.docker.internal:5432/coltura_prod?..."
|
|
|
|
- DATABASE_URL="postgresql://malio:xxx@host.docker.internal:5432/coltura_prod?..."
|
|
|
|
+ DATABASE_URL="postgresql://malio:xxx@host.docker.internal:5432/starseed_prod?..."
|
|
|
|
+ DATABASE_URL="postgresql://malio:xxx@host.docker.internal:5432/starseed_prod?..."
|
|
|
|
- CORS_ALLOW_ORIGIN='^https?://coltura\.malio-dev\.fr$'
|
|
|
|
- CORS_ALLOW_ORIGIN='^http://coltura\.malio-dev\.fr$'
|
|
|
|
+ CORS_ALLOW_ORIGIN='^https?://starseed\.malio-dev\.fr$'
|
|
|
|
+ CORS_ALLOW_ORIGIN='^http://starseed\.malio-dev\.fr$'
|
|
|
|
- DEFAULT_URI=https://coltura.malio-dev.fr
|
|
|
|
- DEFAULT_URI=http://coltura.malio-dev.fr
|
|
|
|
+ DEFAULT_URI=https://starseed.malio-dev.fr
|
|
|
|
+ DEFAULT_URI=http://starseed.malio-dev.fr
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Etape 6 — Stopper et supprimer l'ancien container
|
|
|
|
### 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
|
|
|
|
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
|
|
|
|
```bash
|
|
|
|
sudo cp /var/www/starseed/infra/prod/nginx-proxy.conf /etc/nginx/sites-available/starseed.conf
|
|
|
|
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
|
|
|
|
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
|
|
|
|
```bash
|
|
|
|
# Verifier le DNS d'abord
|
|
|
|
getent hosts starseed.malio-dev.fr || echo "ATTENTION : starseed.malio-dev.fr ne resout pas localement"
|
|
|
|
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
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Puis :
|
|
|
|
Puis :
|
|
|
|
@@ -176,9 +171,9 @@ sudo systemctl reload nginx
|
|
|
|
```bash
|
|
|
|
```bash
|
|
|
|
rm -f /var/www/starseed/maintenance.on
|
|
|
|
rm -f /var/www/starseed/maintenance.on
|
|
|
|
|
|
|
|
|
|
|
|
# Tests externes
|
|
|
|
# Tests externes (HTTP local)
|
|
|
|
curl -s -o /dev/null -w "HTTP %{http_code}\n" https://starseed.malio-dev.fr/
|
|
|
|
curl -s -o /dev/null -w "HTTP %{http_code}\n" http://starseed.malio-dev.fr/
|
|
|
|
curl -s https://starseed.malio-dev.fr/api/version
|
|
|
|
curl -s http://starseed.malio-dev.fr/api/version
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
`/api/version` doit renvoyer du JSON avec la version courante.
|
|
|
|
`/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
|
|
|
|
## Regles de comportement pour le Claude prod
|
|
|
|
|
|
|
|
|
|
|
|
- **Ne jamais skipper le backup** (etape 2).
|
|
|
|
- **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.
|
|
|
|
- **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.
|
|
|
|
- **Si une etape echoue**, NE PAS continuer — declencher le rollback.
|
|
|
|
- **Ne commit rien** sur le repo depuis le serveur prod.
|
|
|
|
- **Ne commit rien** sur le repo depuis le serveur prod.
|
|
|
|
|