Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ node_modules
!.env.example
!.env.production.example
*.local
docker/supabase/volumes/db/data
docker/supabase/volumes/storage
*.tsbuildinfo
api/vendor
api/storage/logs
README.md
DEPLOY.md
27 changes: 1 addition & 26 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
# =============================================================================
# Docker Compose racine + Supabase legacy (front/ et back/ Next.js)
# =============================================================================

# Docker dev (Postgres uniquement) — voir docker-compose.yml
POSTGRES_PASSWORD=postgres
POSTGRES_PORT=54322

KONG_PORT=54321
KONG_ADMIN_PORT=54325
STUDIO_PORT=54323

JWT_SECRET=super-secret-jwt-token-with-at-least-32-characters-long
JWT_EXPIRY=3600

ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InN3b3ItdjIiLCJyb2xlIjoiYW5vbiIsImlhdCI6MTYwMDAwMDAwMCwiZXhwIjoyMDAwMDAwMDAwfQ.placeholder-anon-key
SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InN3b3ItdjIiLCJyb2xlIjoic2VydmljZV9yb2xlIiwiaWF0IjoxNjAwMDAwMDAwMCwiZXhwIjoyMDAwMDAwMDAwfQ.placeholder-service-key

SITE_URL=http://localhost:3000
OPERATOR_TOKEN=operator-token
ENABLE_EMAIL_SIGNUP=true
ENABLE_EMAIL_AUTOCONFIRM=true
SMTP_ADMIN_EMAIL=admin@example.com
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=user
SMTP_PASS=pass
SMTP_SENDER_NAME=Supabase
DB_MAX_POOL_SIZE=20
30 changes: 11 additions & 19 deletions .env.production.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,22 @@

# --- URLs publiques ---
SITE_URL=https://swor.fr
PUBLIC_SUPABASE_URL=https://api.swor.fr
API_URL=https://api.swor.fr

# --- Supabase (mêmes valeurs que docker/supabase/.env) ---
POSTGRES_PASSWORD=change-me-strong-password
POSTGRES_PORT=54322

KONG_PORT=54321
KONG_ADMIN_PORT=54325
STUDIO_PORT=54323
# --- Laravel ---
# Générer avec : cd api && php artisan key:generate --show
APP_KEY=base64:change-me
SANCTUM_STATEFUL_DOMAINS=swor.fr,www.swor.fr
SESSION_DOMAIN=.swor.fr

JWT_SECRET=change-me-jwt-secret-at-least-32-characters
JWT_EXPIRY=3600

ANON_KEY=your-anon-key-jwt
SERVICE_ROLE_KEY=your-service-role-key-jwt
# --- Postgres ---
POSTGRES_DB=swor
POSTGRES_USER=postgres
POSTGRES_PASSWORD=change-me-strong-password

# --- Auth / SMTP ---
OPERATOR_TOKEN=change-me-operator-token
ENABLE_EMAIL_SIGNUP=true
ENABLE_EMAIL_AUTOCONFIRM=false
# --- SMTP (emails transactionnels : vérification, reset password) ---
SMTP_ADMIN_EMAIL=noreply@swor.fr
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=
SMTP_PASS=
SMTP_SENDER_NAME=Swor
DB_MAX_POOL_SIZE=20
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,3 @@ jobs:
run: npm run build -w front
env:
NEXT_PUBLIC_API_URL: http://localhost:8000
NEXT_PUBLIC_SUPABASE_URL: http://localhost:54321
NEXT_PUBLIC_SUPABASE_ANON_KEY: placeholder-anon-key-for-ci
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ next-env.d.ts
.env.local
.env*.local

# Docker local volumes (Postgres data, storage)
docker/supabase/volumes/db/data/
docker/supabase/volumes/storage/

# TypeScript
*.tsbuildinfo

Expand All @@ -52,8 +48,7 @@ api/storage/*.key
api/database/database.sqlite
api/bootstrap/cache/*.php
api/.env
api/node_modules/
api/.phpunit.result.cache
.phpunit.result.cache
/auth.json
Homestead.json
Homestead.yaml
Expand Down
59 changes: 24 additions & 35 deletions DEPLOY.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Swor — déploiement VPS (Docker)

Guide pour remplacer l’ancienne app Laravel sur [swor.fr](https://swor.fr) par le stack Next.js + Supabase.
Stack production : front Next.js + API Laravel + PostgreSQL, derrière Nginx.

> ⚠️ La stack Docker de production (`api/Dockerfile`, `docker-compose.prod.yml`)
> a été réécrite lors de la migration Laravel et n'a pas encore été validée sur
> le VPS — à tester au prochain déploiement.

## Prérequis serveur

- Ubuntu 22.04+ (ou équivalent)
- Docker et Docker Compose v2
- Nginx (ou Caddy) pour le reverse proxy HTTPS
- Nginx pour le reverse proxy HTTPS
- Nom de domaine pointant vers le VPS (`swor.fr`, `api.swor.fr`)

## 1. Préparer le serveur
Expand All @@ -29,41 +33,29 @@ Depuis votre machine locale :
./scripts/deploy.sh user@votre-vps /opt/swor
```

Ou manuellement :

```bash
rsync -avz --delete \
--exclude node_modules \
--exclude .next \
--exclude .git \
--exclude docker/supabase/volumes/db/data \
--exclude docker/supabase/volumes/storage \
./ user@votre-vps:/opt/swor/
```

## 3. Configurer l’environnement
## 3. Configurer l'environnement

Sur le VPS :

```bash
cd /opt/swor
cp .env.production.example .env.production
cp docker/supabase/env.example docker/supabase/.env
```

Éditez `.env.production` et `docker/supabase/.env` :
Éditez `.env.production` :

| Variable | Exemple | Rôle |
|----------|---------|------|
| `SITE_URL` | `https://swor.fr` | URL du front (auth Supabase) |
| `PUBLIC_SUPABASE_URL` | `https://api.swor.fr` | URL API exposée au navigateur |
| `JWT_SECRET` | 32+ caractères | Secret JWT Supabase |
| `ANON_KEY` / `SERVICE_ROLE_KEY` | JWT signés | Clés API (identiques dans les deux fichiers) |
| `SITE_URL` | `https://swor.fr` | URL publique du front |
| `API_URL` | `https://api.swor.fr` | URL publique de l'API (injectée au build du front) |
| `APP_KEY` | `base64:…` | Clé Laravel (`php artisan key:generate --show`) |
| `SANCTUM_STATEFUL_DOMAINS` | `swor.fr,www.swor.fr` | Domaines autorisés pour la session SPA |
| `SESSION_DOMAIN` | `.swor.fr` | Portée du cookie de session |
| `POSTGRES_PASSWORD` | mot de passe fort | Base de données |
| `SMTP_*` | — | Emails transactionnels |

Générez des clés JWT cohérentes avec votre `JWT_SECRET` (ou réutilisez celles du dev en changeant le secret).

> **Important :** `PUBLIC_SUPABASE_URL` est injectée au **build** du front. Après modification, reconstruisez : `docker compose -f docker-compose.prod.yml --env-file .env.production up -d --build`.
> **Important :** `API_URL` est injectée au **build** du front. Après
> modification, reconstruisez : `npm run docker:prod:up`.

## 4. Lancer en production

Expand All @@ -72,14 +64,13 @@ cd /opt/swor
npm run docker:prod:up
```

Services :
Les migrations Laravel s'exécutent automatiquement au démarrage du conteneur API.

| Service | Port interne | Accès recommandé |
|---------|--------------|------------------|
| Front Next.js | 3000 (localhost) | Via Nginx → `swor.fr` |
| Supabase API (Kong) | 54321 | Via Nginx → `api.swor.fr` |
| Supabase Studio | 54323 | Bloquer en prod ou VPN uniquement |
| PostgreSQL | 54322 | Localhost / jamais exposé |
| Front Next.js | 127.0.0.1:3000 | Via Nginx → `swor.fr` |
| API Laravel | 127.0.0.1:8080 | Via Nginx → `api.swor.fr` |
| PostgreSQL | interne Docker | Jamais exposé |

## 5. Nginx (HTTPS)

Expand Down Expand Up @@ -109,19 +100,17 @@ sudo ufw allow 443
sudo ufw enable
```

Ne pas ouvrir les ports 54321, 54322, 54323 publiquement — Nginx fait le proxy.
Ne pas ouvrir les ports 3000 et 8080 publiquement — Nginx fait le proxy.

## Dépannage

```bash
# Logs
docker compose -f docker-compose.prod.yml --env-file .env.production logs -f front
docker compose -f docker-compose.prod.yml --env-file .env.production logs -f api

# Rebuild complet
docker compose -f docker-compose.prod.yml --env-file .env.production up -d --build --force-recreate

# Reset BDD (destructif)
docker compose -f docker-compose.prod.yml --env-file .env.production down
rm -rf docker/supabase/volumes/db/data
docker compose -f docker-compose.prod.yml --env-file .env.production up -d
# Console Laravel dans le conteneur
docker exec -it swor-api php artisan tinker
```
Loading
Loading