Étape 1 : squelette du projet
- Monorepo backend/ + frontend/ + deploy/ - Backend FastAPI/SQLModel/Alembic/uv qui démarre (health check, config, i18n, base de test PostgreSQL, pytest) - docker-compose de développement (db + backend hot-reload) - Chaîne CI/CD GitHub Actions : lint + tests, build image, push GHCR, déploiement SSH sur le VPS à chaque push main - CLAUDE.md : vocabulaire du domaine, conventions, commandes Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017uUsRg7XzopkCPWimwg9ZM
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
# Déploiement
|
||||
|
||||
Le workflow [`.github/workflows/deploy.yml`](../.github/workflows/deploy.yml)
|
||||
se déclenche sur **chaque push sur `main`** :
|
||||
|
||||
1. build de l'image `backend` ;
|
||||
2. push sur `ghcr.io/<owner>/<repo>-backend` (tags `latest` et `sha-<commit>`) ;
|
||||
3. copie de `deploy/docker-compose.prod.yml` sur le VPS par SSH ;
|
||||
4. `docker compose -f docker-compose.prod.yml pull && up -d`.
|
||||
|
||||
## Secrets GitHub Actions requis
|
||||
|
||||
| Secret | Description |
|
||||
|----------------|----------------------------------------------------------------|
|
||||
| `SSH_HOST` | Hôte du VPS |
|
||||
| `SSH_USER` | Utilisateur SSH |
|
||||
| `SSH_KEY` | Clé privée SSH (format OpenSSH) |
|
||||
| `DEPLOY_PATH` | Dossier du projet sur le VPS (ex. `/opt/benevoles`) |
|
||||
| `GHCR_TOKEN` | PAT avec scope `read:packages`, pour que le VPS tire l'image |
|
||||
|
||||
## Préparation du VPS (une fois)
|
||||
|
||||
```bash
|
||||
mkdir -p /opt/benevoles
|
||||
cd /opt/benevoles
|
||||
cat > .env <<'EOF'
|
||||
POSTGRES_USER=benevoles
|
||||
POSTGRES_PASSWORD=<mot de passe fort>
|
||||
POSTGRES_DB=benevoles
|
||||
JWT_SECRET=<secret fort>
|
||||
EOF
|
||||
```
|
||||
|
||||
Le workflow dépose `docker-compose.prod.yml` dans ce dossier et l'utilise tel
|
||||
quel.
|
||||
@@ -0,0 +1,37 @@
|
||||
name: benevoles
|
||||
|
||||
# Déployé sur le VPS. Les variables sont lues depuis un fichier .env situé à
|
||||
# côté de ce fichier (non versionné) : POSTGRES_USER, POSTGRES_PASSWORD,
|
||||
# POSTGRES_DB, JWT_SECRET. BACKEND_IMAGE est exporté par le workflow de déploiement.
|
||||
|
||||
services:
|
||||
db:
|
||||
image: postgres:16-alpine
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
POSTGRES_DB: ${POSTGRES_DB}
|
||||
volumes:
|
||||
- db_data:/var/lib/postgresql/data
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
backend:
|
||||
image: ${BACKEND_IMAGE:-ghcr.io/OWNER/REPO-backend:latest}
|
||||
environment:
|
||||
DATABASE_URL: postgresql+psycopg://${POSTGRES_USER}:${POSTGRES_PASSWORD}@db:5432/${POSTGRES_DB}
|
||||
ENVIRONMENT: production
|
||||
JWT_SECRET: ${JWT_SECRET}
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "8000:8000"
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
db_data:
|
||||
Reference in New Issue
Block a user