# MyEasyCMS v2 — Docker Compose for Production / Dokploy # # Equivalent to `supabase start` but portable for self-hosted deployment. # For local development, use `pnpm supabase:web:start` instead. # # ⚠️ First deploy: `docker compose up -d` creates the DB from scratch with # all Supabase roles/schemas via the image's built-in init scripts, then # runs app migrations from the mounted volume. # # 🔒 Port bindings are intentionally omitted — in Dokploy, Traefik handles # external routing. Services communicate via the Docker network. services: # ===================================================== # Supabase Postgres # ===================================================== supabase-db: image: supabase/postgres:15.8.1.060 restart: unless-stopped volumes: - supabase-db-data:/var/lib/postgresql/data # Post-migration hook: sets passwords on all Supabase roles AFTER # migrate.sh creates them. 'zzz-' prefix ensures it runs last. - ./docker/db/zzz-role-passwords.sh:/docker-entrypoint-initdb.d/zzz-role-passwords.sh:ro # App migrations — mounted to a separate path (NOT /docker-entrypoint-initdb.d/migrations!) - ./apps/web/supabase/migrations:/app-migrations:ro environment: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} POSTGRES_DB: postgres healthcheck: test: ['CMD-SHELL', 'pg_isready -U postgres -d postgres'] interval: 10s timeout: 5s retries: 10 # Run app migrations, seed, and dev patches after DB is healthy. # Also ensures role passwords are set (idempotent) — covers the case # where the DB volume already existed from a previous deployment and # /docker-entrypoint-initdb.d/ scripts didn't re-run. supabase-db-migrate: image: supabase/postgres:15.8.1.060 depends_on: supabase-db: condition: service_healthy volumes: - ./apps/web/supabase/migrations:/app-migrations:ro - ./apps/web/supabase/seed.sql:/app-seed/seed.sql:ro - ./docker/db/dev-bootstrap.sh:/app-seed/dev-bootstrap.sh:ro environment: PGPASSWORD: ${POSTGRES_PASSWORD} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} entrypoint: ['/bin/sh', '-c'] command: - | echo "🔑 Ensuring role passwords are set (idempotent)..." psql -h supabase-db -U supabase_admin -d postgres -v ON_ERROR_STOP=0 -c "ALTER ROLE authenticator WITH LOGIN PASSWORD '${POSTGRES_PASSWORD}';" -c "ALTER ROLE supabase_storage_admin WITH LOGIN PASSWORD '${POSTGRES_PASSWORD}';" -c "ALTER ROLE supabase_auth_admin WITH LOGIN PASSWORD '${POSTGRES_PASSWORD}';" -c "ALTER ROLE dashboard_user WITH LOGIN PASSWORD '${POSTGRES_PASSWORD}';" -c "ALTER ROLE postgres WITH PASSWORD '${POSTGRES_PASSWORD}';" -c "CREATE SCHEMA IF NOT EXISTS _realtime;" -c "GRANT ALL ON SCHEMA _realtime TO supabase_admin;" -c "GRANT USAGE ON SCHEMA _realtime TO postgres, anon, authenticated, service_role;" 2>&1 || true echo "" echo "Running app migrations..." for sql in /app-migrations/*.sql; do echo " → $$sql" psql -h supabase-db -U supabase_admin -d postgres -v ON_ERROR_STOP=0 -f "$$sql" 2>&1 || true done echo "✅ App migrations complete." echo "" sh /app-seed/dev-bootstrap.sh restart: 'no' # ===================================================== # Supabase Auth (GoTrue) # ===================================================== supabase-auth: image: supabase/gotrue:v2.172.1 restart: unless-stopped depends_on: supabase-db: condition: service_healthy supabase-db-migrate: condition: service_completed_successfully environment: GOTRUE_API_HOST: 0.0.0.0 GOTRUE_API_PORT: 9999 API_EXTERNAL_URL: ${API_EXTERNAL_URL:-http://localhost:8000} GOTRUE_DB_DRIVER: postgres GOTRUE_DB_DATABASE_URL: postgres://supabase_auth_admin:${POSTGRES_PASSWORD}@supabase-db:5432/postgres?search_path=auth GOTRUE_SITE_URL: ${SITE_URL:-https://myeasycms.de} GOTRUE_URI_ALLOW_LIST: ${ADDITIONAL_REDIRECT_URLS:-} GOTRUE_DISABLE_SIGNUP: ${DISABLE_SIGNUP:-false} GOTRUE_JWT_ADMIN_ROLES: service_role GOTRUE_JWT_AUD: authenticated GOTRUE_JWT_DEFAULT_GROUP_NAME: authenticated GOTRUE_JWT_EXP: ${JWT_EXPIRY:-3600} GOTRUE_JWT_SECRET: ${JWT_SECRET} GOTRUE_EXTERNAL_EMAIL_ENABLED: true GOTRUE_MAILER_AUTOCONFIRM: ${ENABLE_EMAIL_AUTOCONFIRM:-false} GOTRUE_SMTP_HOST: ${SMTP_HOST:-} GOTRUE_SMTP_PORT: ${SMTP_PORT:-587} GOTRUE_SMTP_USER: ${SMTP_USER:-} GOTRUE_SMTP_PASS: ${SMTP_PASS:-} GOTRUE_SMTP_ADMIN_EMAIL: ${SMTP_ADMIN_EMAIL:-admin@myeasycms.de} GOTRUE_MAILER_URLPATHS_INVITE: /auth/v1/verify GOTRUE_MAILER_URLPATHS_CONFIRMATION: /auth/v1/verify GOTRUE_MAILER_URLPATHS_RECOVERY: /auth/v1/verify GOTRUE_MAILER_URLPATHS_EMAIL_CHANGE: /auth/v1/verify healthcheck: test: [ 'CMD', 'wget', '--no-verbose', '--tries=1', '--spider', 'http://localhost:9999/health', ] interval: 10s timeout: 5s retries: 5 # ===================================================== # Supabase REST (PostgREST) # ===================================================== supabase-rest: image: postgrest/postgrest:v12.2.8 restart: unless-stopped depends_on: supabase-db: condition: service_healthy supabase-db-migrate: condition: service_completed_successfully environment: PGRST_DB_URI: postgres://authenticator:${POSTGRES_PASSWORD}@supabase-db:5432/postgres PGRST_DB_SCHEMAS: public,storage,graphql_public PGRST_DB_ANON_ROLE: anon PGRST_JWT_SECRET: ${JWT_SECRET} PGRST_DB_USE_LEGACY_GUCS: 'false' healthcheck: test: ['CMD-SHELL', 'head -c0 r.statusCode === 200 ? process.exit(0) : process.exit(1))", ] interval: 10s timeout: 5s retries: 5 start_period: 30s # ===================================================== # Supabase Inbucket (Email testing) # ===================================================== supabase-inbucket: image: inbucket/inbucket:3.0.4 restart: unless-stopped volumes: - supabase-inbucket-data:/storage # ===================================================== # Supabase Kong (API Gateway) # ===================================================== supabase-kong: image: kong:2.8.1 restart: unless-stopped depends_on: - supabase-auth - supabase-rest - supabase-storage - supabase-realtime entrypoint: > sh -c "sed 's|\$${SUPABASE_ANON_KEY}|'\"$$SUPABASE_ANON_KEY\"'|g; s|\$${SUPABASE_SERVICE_KEY}|'\"$$SUPABASE_SERVICE_KEY\"'|g' /var/lib/kong/kong.yml.tpl > /tmp/kong.yml && KONG_DECLARATIVE_CONFIG=/tmp/kong.yml /docker-entrypoint.sh kong docker-start" environment: KONG_DATABASE: 'off' KONG_DECLARATIVE_CONFIG: /var/lib/kong/kong.yml KONG_DNS_ORDER: LAST,A,CNAME KONG_PLUGINS: request-transformer,cors,key-auth,acl,basic-auth KONG_NGINX_PROXY_PROXY_BUFFER_SIZE: 160k KONG_NGINX_PROXY_PROXY_BUFFERS: 64 160k SUPABASE_ANON_KEY: ${SUPABASE_ANON_KEY} SUPABASE_SERVICE_KEY: ${SUPABASE_SERVICE_ROLE_KEY} volumes: - ./docker/kong.yml:/var/lib/kong/kong.yml.tpl:ro healthcheck: test: ['CMD', 'kong', 'health'] interval: 10s timeout: 5s retries: 5 # ===================================================== # Next.js App # ===================================================== app: build: context: . dockerfile: Dockerfile args: NEXT_PUBLIC_SITE_URL: ${SITE_URL:-https://myeasycms.de} # Browser-side Supabase URL — goes through external domain (Traefik → Kong) NEXT_PUBLIC_SUPABASE_URL: ${API_EXTERNAL_URL:-http://localhost:8000} NEXT_PUBLIC_SUPABASE_PUBLIC_KEY: ${SUPABASE_ANON_KEY} restart: unless-stopped depends_on: supabase-kong: condition: service_healthy supabase-db-migrate: condition: service_completed_successfully environment: NODE_ENV: production NEXT_PUBLIC_SITE_URL: ${SITE_URL:-http://localhost:3000} # Same URL for browser AND server — keeps Supabase cookie names consistent NEXT_PUBLIC_SUPABASE_URL: ${API_EXTERNAL_URL:-http://localhost:8000} NEXT_PUBLIC_SUPABASE_PUBLIC_KEY: ${SUPABASE_ANON_KEY} NEXT_PUBLIC_DEFAULT_LOCALE: de SUPABASE_SECRET_KEY: ${SUPABASE_SERVICE_ROLE_KEY} SUPABASE_DB_WEBHOOK_SECRET: ${DB_WEBHOOK_SECRET:-webhooksecret} EMAIL_SENDER: ${EMAIL_SENDER:-noreply@myeasycms.de} NEXT_PUBLIC_PRODUCT_NAME: MyEasyCMS NEXT_PUBLIC_ENABLE_THEME_TOGGLE: 'true' NEXT_PUBLIC_ENABLE_TEAM_ACCOUNTS: 'true' NEXT_PUBLIC_ENABLE_TEAM_ACCOUNTS_CREATION: 'true' NEXT_PUBLIC_ENABLE_TEAM_ACCOUNTS_BILLING: 'false' NEXT_PUBLIC_ENABLE_PERSONAL_ACCOUNT_BILLING: 'false' NEXT_PUBLIC_ENABLE_NOTIFICATIONS: 'true' volumes: supabase-db-data: supabase-storage-data: supabase-inbucket-data: