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
This commit is contained in:
@@ -7,9 +7,14 @@ services:
|
||||
- "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:
|
||||
@@ -18,6 +23,7 @@ services:
|
||||
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}
|
||||
@@ -25,8 +31,39 @@ services:
|
||||
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:
|
||||
@@ -34,4 +71,5 @@ services:
|
||||
restart: always
|
||||
|
||||
volumes:
|
||||
codeboard_postgres_data:
|
||||
codeboard_redis_data:
|
||||
|
||||
Reference in New Issue
Block a user