# Shared environment variables
x-common-env: &common-env
  STEGASOO_CHANNEL_KEY: ${STEGASOO_CHANNEL_KEY:-}

services:
  # ============================================================================
  # Web UI (Flask)
  # ============================================================================
  web:
    build:
      context: ..
      dockerfile: docker/Dockerfile
      target: web
    container_name: stegasoo-web
    ports:
      - "5000:5000"
    environment:
      <<: *common-env
      FLASK_ENV: production
      # Authentication (v4.0.2)
      STEGASOO_AUTH_ENABLED: ${STEGASOO_AUTH_ENABLED:-true}
      # HTTPS enabled by default - generates self-signed cert if none provided
      # To disable: STEGASOO_HTTPS_ENABLED=false docker-compose up
      STEGASOO_HTTPS_ENABLED: ${STEGASOO_HTTPS_ENABLED:-true}
      STEGASOO_HOSTNAME: ${STEGASOO_HOSTNAME:-localhost}
    volumes:
      # Persist auth database and SSL certs (v4.0.2)
      - stegasoo-web-data:/app/frontends/web/instance
      - stegasoo-web-certs:/app/frontends/web/certs
    restart: unless-stopped
    deploy:
      resources:
        limits:
          memory: 2048M
        reservations:
          memory: 1024M

  # ============================================================================
  # REST API (FastAPI)
  # ============================================================================
  api:
    build:
      context: ..
      dockerfile: docker/Dockerfile
      target: api
    container_name: stegasoo-api
    ports:
      - "8000:8000"
    environment:
      <<: *common-env
    restart: unless-stopped
    deploy:
      resources:
        limits:
          memory: 2048M
        reservations:
          memory: 1024M

# Named volumes for persistent data
volumes:
  stegasoo-web-data:
    driver: local
  stegasoo-web-certs:
    driver: local
