services:
  backend:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: financial-system-backend
    environment:
      APP_CONFIG_FILE: /app/config/app_settings.json
      DATABASE_URL: ${DATABASE_URL:?Please set DATABASE_URL in .env}
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ports:
      - "${BACKEND_PORT:-8000}:8000"
    volumes:
      - ./config/app_settings.json:/app/config/app_settings.json:ro
      - ./uploads:/app/uploads
      - ./outputs:/app/outputs
      - ./logs:/app/logs
      - ./static/uploads:/app/static/uploads
    healthcheck:
      test:
        [
          "CMD",
          "python",
          "-c",
          "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health', timeout=2)",
        ]
      interval: 15s
      timeout: 5s
      retries: 10
      start_period: 20s
    restart: unless-stopped

  frontend:
    build:
      context: .
      dockerfile: frontend/Dockerfile
      args:
        VITE_API_BASE_URL: ""
    container_name: financial-system-frontend
    depends_on:
      backend:
        condition: service_started
    ports:
      - "${FRONTEND_PORT:-5173}:80"
    restart: unless-stopped
