Track A (Infrastructure & Data Layer): - docker-compose.yml with all 7 services (nginx, frontend, api, mcp, renderer, worker, postgres, redis) - docker-compose.override.yml for local dev (hot reload, port exposure) - PostgreSQL init.sql with full schema (15 tables, pgvector indexes, creator economy stubs) - .env.example with all required environment variables Track A+B (API Layer): - FastAPI app with 10 routers (auth, shaders, feed, votes, generate, desires, users, payments, mcp_keys, health) - SQLAlchemy ORM models for all 15 tables - Pydantic schemas for all request/response types - JWT auth middleware (access + refresh tokens, Redis blocklist) - Redis rate limiting middleware - Celery worker config with job stubs (render, embed, generate, feed cache, expire bounties) - Alembic migration framework Service stubs: - MCP server (health endpoint, 501 for all tools) - Renderer service (Express + Puppeteer scaffold, 501 for /render) - Frontend (package.json with React/Vite/Three.js/TanStack/Tailwind deps) - Nginx reverse proxy config (/, /api, /mcp, /renders) Project: - DECISIONS.md with 11 recorded architectural decisions - README.md with architecture overview - Sample shader seed data (plasma, fractal noise, raymarched sphere)
144 lines
5.1 KiB
YAML
144 lines
5.1 KiB
YAML
version: "3.9"
|
|
|
|
services:
|
|
|
|
# ─── Reverse Proxy ──────────────────────────────────────────
|
|
nginx:
|
|
image: nginx:alpine
|
|
ports:
|
|
- "80:80"
|
|
- "443:443"
|
|
volumes:
|
|
- ./services/nginx/conf:/etc/nginx/conf.d:ro
|
|
- ./services/nginx/certs:/etc/ssl/certs:ro
|
|
depends_on:
|
|
api:
|
|
condition: service_healthy
|
|
frontend:
|
|
condition: service_started
|
|
restart: unless-stopped
|
|
|
|
# ─── Frontend (React + Vite) ────────────────────────────────
|
|
frontend:
|
|
build:
|
|
context: ./services/frontend
|
|
dockerfile: Dockerfile
|
|
environment:
|
|
- VITE_API_URL=${VITE_API_URL:-http://localhost/api}
|
|
- VITE_MCP_URL=${VITE_MCP_URL:-http://localhost/mcp}
|
|
restart: unless-stopped
|
|
|
|
# ─── API (FastAPI) ──────────────────────────────────────────
|
|
api:
|
|
build:
|
|
context: ./services/api
|
|
dockerfile: Dockerfile
|
|
environment:
|
|
- DATABASE_URL=postgresql+asyncpg://${POSTGRES_USER:-fracta}:${DB_PASS}@postgres:5432/${POSTGRES_DB:-fractafrag}
|
|
- DATABASE_URL_SYNC=postgresql://${POSTGRES_USER:-fracta}:${DB_PASS}@postgres:5432/${POSTGRES_DB:-fractafrag}
|
|
- REDIS_URL=${REDIS_URL:-redis://redis:6379/0}
|
|
- JWT_SECRET=${JWT_SECRET}
|
|
- JWT_ALGORITHM=${JWT_ALGORITHM:-HS256}
|
|
- JWT_ACCESS_TOKEN_EXPIRE_MINUTES=${JWT_ACCESS_TOKEN_EXPIRE_MINUTES:-15}
|
|
- JWT_REFRESH_TOKEN_EXPIRE_DAYS=${JWT_REFRESH_TOKEN_EXPIRE_DAYS:-30}
|
|
- TURNSTILE_SECRET=${TURNSTILE_SECRET}
|
|
- STRIPE_SECRET_KEY=${STRIPE_SECRET_KEY}
|
|
- STRIPE_WEBHOOK_SECRET=${STRIPE_WEBHOOK_SECRET}
|
|
- RENDERER_URL=http://renderer:3100
|
|
- BYOK_MASTER_KEY=${BYOK_MASTER_KEY}
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
restart: unless-stopped
|
|
|
|
# ─── MCP Server ─────────────────────────────────────────────
|
|
mcp:
|
|
build:
|
|
context: ./services/mcp
|
|
dockerfile: Dockerfile
|
|
environment:
|
|
- API_BASE_URL=http://api:8000
|
|
- MCP_API_KEY_SALT=${MCP_API_KEY_SALT}
|
|
- REDIS_URL=${REDIS_URL:-redis://redis:6379/0}
|
|
depends_on:
|
|
api:
|
|
condition: service_healthy
|
|
restart: unless-stopped
|
|
|
|
# ─── Renderer (Headless Chromium) ───────────────────────────
|
|
renderer:
|
|
build:
|
|
context: ./services/renderer
|
|
dockerfile: Dockerfile
|
|
shm_size: "512mb"
|
|
environment:
|
|
- MAX_RENDER_DURATION=${MAX_RENDER_DURATION:-8}
|
|
- OUTPUT_DIR=${RENDER_OUTPUT_DIR:-/renders}
|
|
volumes:
|
|
- renders:/renders
|
|
restart: unless-stopped
|
|
|
|
# ─── Worker (Celery) ────────────────────────────────────────
|
|
worker:
|
|
build:
|
|
context: ./services/api
|
|
dockerfile: Dockerfile
|
|
command: celery -A app.worker.celery_app worker --loglevel=info --concurrency=4
|
|
environment:
|
|
- DATABASE_URL=postgresql+asyncpg://${POSTGRES_USER:-fracta}:${DB_PASS}@postgres:5432/${POSTGRES_DB:-fractafrag}
|
|
- DATABASE_URL_SYNC=postgresql://${POSTGRES_USER:-fracta}:${DB_PASS}@postgres:5432/${POSTGRES_DB:-fractafrag}
|
|
- REDIS_URL=${REDIS_URL:-redis://redis:6379/0}
|
|
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
|
|
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
|
- RENDERER_URL=http://renderer:3100
|
|
- BYOK_MASTER_KEY=${BYOK_MASTER_KEY}
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
renderer:
|
|
condition: service_started
|
|
restart: unless-stopped
|
|
|
|
# ─── PostgreSQL + pgvector ──────────────────────────────────
|
|
postgres:
|
|
image: pgvector/pgvector:pg16
|
|
environment:
|
|
- POSTGRES_USER=${POSTGRES_USER:-fracta}
|
|
- POSTGRES_PASSWORD=${DB_PASS}
|
|
- POSTGRES_DB=${POSTGRES_DB:-fractafrag}
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql/data
|
|
- ./db/init.sql:/docker-entrypoint-initdb.d/01-init.sql:ro
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-fracta} -d ${POSTGRES_DB:-fractafrag}"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
restart: unless-stopped
|
|
|
|
# ─── Redis ──────────────────────────────────────────────────
|
|
redis:
|
|
image: redis:7-alpine
|
|
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
|
|
volumes:
|
|
- redisdata:/data
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
pgdata:
|
|
redisdata:
|
|
renders:
|