# PRODUCTION DEPLOYMENT — Uses pre-built images from GHCR
# Usage: IMAGE_TAG=v1.2.3 docker compose -f docker-compose.prod.yml up -d

services:
  backend:
    image: ghcr.io/gyfsoo/blob-backend/backend:${IMAGE_TAG:-latest}
    ports:
      - "127.0.0.1:8000:8000"
    env_file:
      - .env.prod
    depends_on:
      redis:
        condition: service_healthy
    networks:
      - blob-network
    restart: unless-stopped
    deploy:
      resources:
        limits:
          memory: 2G
    healthcheck:
      test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"

  redis:
    image: redis:7-alpine
    volumes:
      - redis-data:/data
    command: redis-server --appendonly yes
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 3s
      retries: 5
    networks:
      - blob-network
    restart: unless-stopped
    logging:
      driver: json-file
      options:
        max-size: "5m"
        max-file: "3"

volumes:
  redis-data:

networks:
  blob-network:
    driver: bridge
