services: # ── Backend (Rust / Axum) ────────────────────────────────────────────────── backend: build: ./k-tv-backend ports: - "${BACKEND_PORT:-3000}:3000" environment: - HOST=0.0.0.0 - PORT=3000 - DATABASE_URL=sqlite:///app/data/k-tv.db?mode=rwc # Allow requests from the browser (the user-facing frontend URL) - CORS_ALLOWED_ORIGINS=${CORS_ALLOWED_ORIGINS} # Auth — generate with: openssl rand -hex 32 - JWT_SECRET=${JWT_SECRET} # Cookie secret — generate with: openssl rand -base64 64 - COOKIE_SECRET=${COOKIE_SECRET} - JWT_EXPIRY_HOURS=${JWT_EXPIRY_HOURS:-24} - SECURE_COOKIE=${SECURE_COOKIE:-false} - PRODUCTION=${PRODUCTION:-false} - ALLOW_REGISTRATION=${ALLOW_REGISTRATION:-true} - DB_MAX_CONNECTIONS=${DB_MAX_CONNECTIONS:-5} - DB_MIN_CONNECTIONS=${DB_MIN_CONNECTIONS:-1} # Jellyfin — all three required for schedule generation - JELLYFIN_BASE_URL=${JELLYFIN_BASE_URL} - JELLYFIN_API_KEY=${JELLYFIN_API_KEY} - JELLYFIN_USER_ID=${JELLYFIN_USER_ID} volumes: - backend_data:/app/data restart: unless-stopped healthcheck: test: ["CMD-SHELL", "curl -f http://localhost:3000/api/v1/config || exit 1"] interval: 30s timeout: 5s retries: 3 # ── Frontend (Next.js) ──────────────────────────────────────────────────── frontend: build: context: ./k-tv-frontend args: # Browser-visible backend URL — baked into the client bundle at build time. # Rebuild the image after changing this. NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:4000/api/v1} ports: - "${FRONTEND_PORT:-3001}:3001" environment: # Server-side API URL — uses Docker's internal network, never exposed. # Next.js API routes (e.g. /api/stream/[channelId]) use this. API_URL: http://backend:3000/api/v1 depends_on: backend: condition: service_healthy restart: unless-stopped volumes: backend_data: # ── Optional: PostgreSQL ─────────────────────────────────────────────────── # Uncomment the db service and set DATABASE_URL in backend's environment: # DATABASE_URL: postgres://ktv:${POSTGRES_PASSWORD}@db:5432/ktv # # db: # image: postgres:16-alpine # environment: # POSTGRES_USER: ktv # POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} # POSTGRES_DB: ktv # volumes: # - db_data:/var/lib/postgresql/data # restart: unless-stopped # # db_data: