Guides
Deploiement
Guide de deploiement Coolify pour la plateforme etouch (staging et production)
etouch est deploye sur un VPS gere par Coolify avec des environnements staging et production.
- Frontend :
apps/web(Next.js 15) - API :
apps/api(Hono + GraphQL) - Workers :
packages/workers(BullMQ)
1. Variables d'environnement
Coolify utilise des Environment Groups pour centraliser les variables. Trois groupes :
etouch-shared-- secrets identiques en staging/productionetouch-staging-- URLs et credentials stagingetouch-production-- URLs et credentials production
1.1 Variables partagees (etouch-shared)
| Variable | Description |
|---|---|
NODE_ENV=production | Mode production |
LOG_LEVEL | info en prod, debug en staging |
REDIS_URL | Connection Redis (BullMQ) |
R2_BUCKET | Bucket Cloudflare R2 |
R2_ENDPOINT | Endpoint S3-compatible |
R2_PUBLIC_BASE_URL | CDN public pour R2 |
R2_ACCESS_KEY_ID / R2_SECRET_ACCESS_KEY | Credentials R2 |
RESEND_API_KEY / RESEND_FROM_EMAIL | Email delivery |
EMAIL_SERVICE | resend, sendgrid ou console |
INSEE_INTEGRATION_KEY | API INSEE (optionnel) |
CLOUDFLARE_IMAGES_ACCOUNT_ID / CLOUDFLARE_IMAGES_API_TOKEN | Cloudflare Images |
WORKFLOW_WEBHOOK_SECRET | Webhook workflows (optionnel) |
Generer des secrets uniques par environnement :
AUTH_JWT_SECRET-- minimum 32 caracteresBETTER_AUTH_SECRET--openssl rand -base64 32
1.2 Overrides staging (etouch-staging)
| Variable | Valeur staging |
|---|---|
DATABASE_URL | PostgreSQL staging (Neon) |
AUTH_BASE_URL | https://etouch-staging.e-do.studio |
API_BASE_URL | https://etouch-staging.e-do.studio/api |
NEXT_PUBLIC_SITE_URL | https://etouch-staging.e-do.studio |
NEXT_PUBLIC_API_URL | https://etouch-staging.e-do.studio/api |
CORS_ORIGIN | https://etouch-staging.e-do.studio |
INTERNAL_API_URL | http://etouch-api-staging:3000 |
1.3 Overrides production (etouch-production)
| Variable | Valeur production |
|---|---|
DATABASE_URL | Neon production |
AUTH_BASE_URL | https://etouch.e-do.studio |
API_BASE_URL | https://etouch.e-do.studio/api |
NEXT_PUBLIC_SITE_URL | https://etouch.e-do.studio |
NEXT_PUBLIC_API_URL | https://etouch.e-do.studio/api |
CORS_ORIGIN | https://etouch.e-do.studio |
INTERNAL_API_URL | http://etouch-api:3000 |
2. Configuration des services Coolify
2.1 Service API (apps/api)
- Type : Docker (Dockerfile existant)
- Base directory :
/ - Dockerfile :
/apps/api/Dockerfile - Port conteneur : 3000
- Healthcheck :
GET /healthz - Domaines : aucun (le web app proxy via
/api/*)
Le conteneur API execute automatiquement prisma migrate deploy au demarrage (avec retries). Desactiver avec SKIP_MIGRATIONS=true.
2.2 Service Web (apps/web)
- Type : Node.js (Next.js)
- Base directory :
/ - Port : 3000
- Domaines : staging
etouch-staging.e-do.studio, prodetouch.e-do.studio - Healthcheck :
GET /api/health
| Etape | Commande |
|---|---|
| Install | pnpm install --frozen-lockfile --config.prod=false -r |
| Build | pnpm prisma:generate && pnpm --filter @etouch/db build && pnpm --filter @etouch/web build |
| Start | pnpm --filter @etouch/web start -- --hostname 0.0.0.0 --port 3000 |
Les requetes /api/* sont proxiees vers le conteneur API via INTERNAL_API_URL.
2.3 Workers (packages/workers)
- Type : Service Node.js background
- Domaines/ports : aucun
- Healthcheck : desactive
| Etape | Commande |
|---|---|
| Install | pnpm install --frozen-lockfile --config.prod=false -r |
| Build | pnpm prisma:generate && pnpm --filter @etouch/db build && pnpm --filter @etouch/workers build |
| Start | pnpm prisma:deploy && pnpm --filter @etouch/workers start |
3. Checklist de deploiement
- DNS pointe vers le VPS Coolify pour staging et production
- Environment Groups attaches a chaque application
INTERNAL_API_URLreference le bon conteneur API- Redis et PostgreSQL accessibles depuis le VPS
prisma migrate deploys'execute correctement- Certificats Let's Encrypt emis via Coolify
- Workers en ligne et traitant les queues BullMQ
4. Commandes utiles
- Deploiement staging : push sur la branche staging ou "Redeploy" dans Coolify
- Deploiement production : meme approche une fois staging valide
- Migrations manuelles :
pnpm prisma:deploydans le conteneur API - Inspection des queues : se connecter a Redis et monitorer BullMQ