Files
codeboard/docker-compose.yml
Vectry 30bfd88075 feat: add PostgreSQL persistence for permanent shareable links
- Add PostgreSQL service to docker-compose with health checks
- Add migrate service that runs prisma migrate deploy on startup
- Integrate Prisma client in worker: checks for existing generations
  (same repo+commit) before regenerating, writes to Postgres on completion
- Update /api/docs/[id] with Redis → PostgreSQL fallback + cache repopulation
- Update Dockerfile: prisma generate in build, copy Prisma engine to worker/web
- Add @codeboard/database dependency to web and worker packages
- Add initial SQL migration for Generation and User tables
- Change removeOnComplete to { age: 3600 } for job retention
2026-02-09 20:23:41 +00:00

76 lines
1.9 KiB
YAML

services:
web:
build:
context: .
target: web
ports:
- "4100:3000"
environment:
- REDIS_URL=redis://redis:6379
- DATABASE_URL=postgresql://codeboard:codeboard@postgres:5432/codeboard
depends_on:
redis:
condition: service_started
postgres:
condition: service_healthy
migrate:
condition: service_completed_successfully
restart: always
worker:
build:
context: .
target: worker
environment:
- REDIS_URL=redis://redis:6379
- DATABASE_URL=postgresql://codeboard:codeboard@postgres:5432/codeboard
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
- LLM_MODEL=${LLM_MODEL:-kimi-k2-turbo-preview}
- LLM_BASE_URL=${LLM_BASE_URL:-https://api.moonshot.ai/v1}
depends_on:
redis:
condition: service_started
postgres:
condition: service_healthy
migrate:
condition: service_completed_successfully
restart: always
postgres:
image: postgres:16-alpine
environment:
- POSTGRES_USER=codeboard
- POSTGRES_PASSWORD=codeboard
- POSTGRES_DB=codeboard
volumes:
- codeboard_postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U codeboard"]
interval: 5s
timeout: 5s
retries: 5
restart: always
migrate:
build:
context: .
target: builder
command: npx prisma migrate deploy --schema=packages/database/prisma/schema.prisma
environment:
- DATABASE_URL=postgresql://codeboard:codeboard@postgres:5432/codeboard
depends_on:
postgres:
condition: service_healthy
restart: "no"
redis:
image: redis:7-alpine
volumes:
- codeboard_redis_data:/data
restart: always
volumes:
codeboard_postgres_data:
codeboard_redis_data: