Files
certvia/docker-compose.coolify.yml
T
msolarczekandClaude Opus 4.8 52e30010f1 Feat: optionaler Demo-Seed im migrate-Job via RUN_DEMO_SEED (Testserver)
Der migrate-Container beendet sich nach 'migrate deploy' (restart:no) und der
app-Container hat kein tsx/keine Seed-Dateien -> manueller Seed unpraktisch.
Lösung: migrate führt bei RUN_DEMO_SEED=true nach der Migration den idempotenten
Demo-Seed aus (admin@demo.example / Demo1234!). In Prod die Variable weglassen.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-20 14:22:43 +02:00

99 lines
3.2 KiB
YAML

# Coolify-Deployment (Testserver, intern) — abgeleitet von docker-compose.yml.
# Unterschiede zum lokalen Dev-Compose:
# - keine host "ports": Coolify-Proxy routet die Domain intern auf app:3000
# - Konfiguration über Coolify-Env-Variablen statt env_file: .env
# - Service "migrate": Init-Job (prisma migrate deploy), läuft einmalig VOR app
# - kein mailhog/worker (Dev bzw. noch nicht lauffähig)
# In Coolify als "Docker Compose Location" -> docker-compose.coolify.yml setzen.
services:
# Einmaliger Migrations-Job. Nutzt die builder-Stage (volle node_modules inkl.
# Prisma-CLI/tsx), da die runner-Stage kein Prisma-CLI enthält. Idempotent.
# Optionaler Demo-Seed nur, wenn RUN_DEMO_SEED=true (Testserver) — der Seed ist
# idempotent (upserts). In Produktion die Variable NICHT setzen.
migrate:
build:
context: .
target: builder
command: sh -c "npx prisma migrate deploy && if [ \"$$RUN_DEMO_SEED\" = \"true\" ]; then echo '>> Demo-Seed läuft…'; npx tsx prisma/seed.ts; else echo '>> Demo-Seed übersprungen (RUN_DEMO_SEED != true)'; fi"
environment:
DATABASE_URL: ${DATABASE_URL}
RUN_DEMO_SEED: ${RUN_DEMO_SEED:-false}
depends_on:
postgres:
condition: service_healthy
restart: "no"
app:
build:
context: .
target: runner
environment:
DATABASE_URL: ${DATABASE_URL}
REDIS_URL: ${REDIS_URL}
AUTH_SECRET: ${AUTH_SECRET}
AUTH_URL: ${AUTH_URL}
S3_ENDPOINT: ${S3_ENDPOINT}
S3_ACCESS_KEY: ${S3_ACCESS_KEY}
S3_SECRET_KEY: ${S3_SECRET_KEY}
S3_BUCKET: ${S3_BUCKET}
AI_PROVIDER: ${AI_PROVIDER}
AI_API_KEY: ${AI_API_KEY}
SMTP_HOST: ${SMTP_HOST}
SMTP_PORT: ${SMTP_PORT}
SMTP_USER: ${SMTP_USER}
SMTP_PASSWORD: ${SMTP_PASSWORD}
SMTP_FROM: ${SMTP_FROM}
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_started
minio:
condition: service_started
migrate:
condition: service_completed_successfully
healthcheck:
# Dependency-frei (node ist im Image vorhanden); alles < 500 gilt als gesund
test: ["CMD", "node", "-e", "require('http').get('http://127.0.0.1:3000/',r=>process.exit(r.statusCode<500?0:1)).on('error',()=>process.exit(1))"]
interval: 15s
timeout: 5s
retries: 10
start_period: 30s
restart: unless-stopped
postgres:
image: pgvector/pgvector:pg16
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
interval: 5s
timeout: 5s
retries: 10
restart: unless-stopped
redis:
image: redis:7-alpine
volumes:
- redisdata:/data
restart: unless-stopped
minio:
image: minio/minio:latest
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: ${MINIO_ROOT_USER}
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
volumes:
- miniodata:/data
restart: unless-stopped
volumes:
pgdata:
redisdata:
miniodata: