# Produzione — Match Live TV # Uso: docker compose -f docker-compose.prod.yml --env-file .env up -d --build services: postgres: image: postgres:16-alpine restart: unless-stopped environment: POSTGRES_DB: matchlivetv POSTGRES_USER: postgres POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} volumes: - postgres_data:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 5s timeout: 5s retries: 5 redis: image: redis:7-alpine restart: unless-stopped volumes: - redis_data:/data healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 5s timeout: 3s retries: 5 mediamtx: image: bluenviron/mediamtx:latest restart: unless-stopped ports: - "1935:1935" # RTMP ingest (telefoni) — esporre su router - "8888:8888" # HLS playback (opzionale) volumes: - ./mediamtx.yml:/mediamtx.yml:ro - ./slates:/slates:ro - recordings:/recordings command: /mediamtx.yml healthcheck: test: ["CMD", "wget", "-q", "--spider", "http://127.0.0.1:9997/v3/config/global/get"] interval: 15s timeout: 5s retries: 3 rails: build: context: ../backend dockerfile: Dockerfile restart: unless-stopped command: > bash -c "bundle exec rails db:prepare && bundle exec rails server -b 0.0.0.0 -p 3000 -e production" environment: RAILS_ENV: production DATABASE_URL: postgresql://postgres:${POSTGRES_PASSWORD}@postgres:5432/matchlivetv REDIS_URL: redis://redis:6379/0 MEDIAMTX_API_URL: http://mediamtx:9997 MEDIAMTX_RTMP_URL: ${MEDIAMTX_RTMP_URL:-rtmp://mediamtx:1935} MEDIAMTX_WEBHOOK_SECRET: ${MEDIAMTX_WEBHOOK_SECRET} RAILS_WEBHOOK_URL: http://rails:3000 SECRET_KEY_BASE: ${SECRET_KEY_BASE} JWT_SECRET: ${JWT_SECRET} CORS_ORIGINS: ${CORS_ORIGINS:-*} ALLOWED_HOSTS: ${ALLOWED_HOSTS:-*} YOUTUBE_CLIENT_ID: ${YOUTUBE_CLIENT_ID:-} YOUTUBE_CLIENT_SECRET: ${YOUTUBE_CLIENT_SECRET:-} YOUTUBE_REDIRECT_URI: ${YOUTUBE_REDIRECT_URI:-} HLS_PUBLIC_URL: ${HLS_PUBLIC_URL:-http://localhost:8888} APP_PUBLIC_URL: ${APP_PUBLIC_URL:-http://localhost:3000} RAILS_LOG_TO_STDOUT: "true" RAILS_LOG_LEVEL: ${RAILS_LOG_LEVEL:-info} ports: - "3000:3000" # Solo LAN — NPM proxy HTTPS depends_on: postgres: condition: service_healthy redis: condition: service_healthy mediamtx: condition: service_started volumes: - recordings:/recordings healthcheck: test: ["CMD", "curl", "-f", "http://127.0.0.1:3000/up"] interval: 15s timeout: 5s retries: 10 start_period: 90s sidekiq: build: context: ../backend dockerfile: Dockerfile restart: unless-stopped command: bundle exec sidekiq -C config/sidekiq.yml -e production environment: RAILS_ENV: production DATABASE_URL: postgresql://postgres:${POSTGRES_PASSWORD}@postgres:5432/matchlivetv REDIS_URL: redis://redis:6379/0 MEDIAMTX_API_URL: http://mediamtx:9997 MEDIAMTX_WEBHOOK_SECRET: ${MEDIAMTX_WEBHOOK_SECRET} RAILS_WEBHOOK_URL: http://rails:3000 SECRET_KEY_BASE: ${SECRET_KEY_BASE} JWT_SECRET: ${JWT_SECRET} YOUTUBE_CLIENT_ID: ${YOUTUBE_CLIENT_ID:-} YOUTUBE_CLIENT_SECRET: ${YOUTUBE_CLIENT_SECRET:-} HLS_PUBLIC_URL: ${HLS_PUBLIC_URL:-http://localhost:8888} APP_PUBLIC_URL: ${APP_PUBLIC_URL:-http://localhost:3000} depends_on: rails: condition: service_healthy volumes: postgres_data: redis_data: recordings: