CRA-Helper/docker-compose.yml
sylvain p a891b56360 Add Docker stack for self-hosted deployment
Brings full Postgres + api + web compose setup so the app can run on any
machine with just Docker, instead of requiring a host PostgreSQL install.
Includes a one-shot migrate service that pushes the Drizzle schema before
the API starts. Web image serves the Vite build via nginx and proxies
/api/* to the api-server.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 12:11:36 +02:00

57 lines
1.4 KiB
YAML

services:
postgres:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-cra}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-cra}
POSTGRES_DB: ${POSTGRES_DB:-cra}
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-cra} -d ${POSTGRES_DB:-cra}"]
interval: 5s
timeout: 3s
retries: 10
migrate:
build:
context: .
dockerfile: docker/api.Dockerfile
target: migrate
environment:
DATABASE_URL: postgres://${POSTGRES_USER:-cra}:${POSTGRES_PASSWORD:-cra}@postgres:5432/${POSTGRES_DB:-cra}
depends_on:
postgres:
condition: service_healthy
restart: "no"
api:
build:
context: .
dockerfile: docker/api.Dockerfile
target: runtime-api
restart: unless-stopped
environment:
DATABASE_URL: postgres://${POSTGRES_USER:-cra}:${POSTGRES_PASSWORD:-cra}@postgres:5432/${POSTGRES_DB:-cra}
PORT: "3000"
NODE_ENV: production
depends_on:
postgres:
condition: service_healthy
migrate:
condition: service_completed_successfully
web:
build:
context: .
dockerfile: docker/web.Dockerfile
restart: unless-stopped
ports:
- "${WEB_PORT:-8080}:80"
depends_on:
- api
volumes:
postgres_data: