# STAGING VM DEPLOYMENT — api.staging.gyfsoo.com (future VM)
# Binds to localhost:8000 only — Nginx reverse-proxies public traffic (80/443)
# Usage: IMAGE_TAG=staging-latest docker compose -f docker-compose.staging.yml up -d

services:
  backend:
    image: ghcr.io/gyfsoo/blob-backend/backend:${IMAGE_TAG:-staging-latest}
    ports:
      - "127.0.0.1:8000:8000"
    env_file:
      - .env.staging
    volumes:
      - /root/.config/gcloud:/root/.config/gcloud:ro
    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

volumes:
  redis-data:

networks:
  blob-network:
    driver: bridge

