services:
  web:
    profiles: ["docker-web"]
    build:
      context: .
      dockerfile: apps/web/Dockerfile
    ports:
      - "5173:5173"
    environment:
      VITE_USE_API_PROXY: "true"
      VITE_API_URL: http://api:8000
      # File-watcher polling for bind-mounted sources on Windows/macOS
      CHOKIDAR_USEPOLLING: "true"
      WATCHPACK_POLLING: "true"
    volumes:
      # Live-reload: mount the whole monorepo so workspace packages stay in sync
      - .:/app
      # Anonymous volumes: keep container-installed node_modules from being
      # overwritten by the host (empty dir or different OS/arch binaries)
      - /app/node_modules
      - /app/apps/web/node_modules
    depends_on:
      - api
      - postgres
      - redis
      - minio

  api:
    build: ./apps/api
    ports:
      - "8000:8000"
    environment:
      S3_ENDPOINT: http://minio:9000
      STORAGE_MODE: s3
      REDIS_URL: redis://redis:6379/0
      CORS_ORIGINS: '["http://localhost:5173","http://127.0.0.1:5173"]'
      FRONTEND_URL: http://localhost:5173
      PUBLIC_BASE_URL: http://localhost:5173
      COOKIE_SECURE: "false"
      EMAIL_DELIVERY_MODE: memory
      ENABLE_RATE_LIMIT: "true"
    env_file:
      - ./apps/api/.env.example
      - ./apps/api/data/secrets/install.env
    volumes:
      - ./apps/api/data/secrets:/app/data/secrets
    depends_on:
      - postgres
      - redis
      - minio

  postgres:
    image: postgres:16
    env_file:
      - ./apps/api/data/secrets/install.env
  redis:
    image: redis:7-alpine

  minio:
    image: minio/minio
    command: server /data --console-address ":9001"
    env_file:
      - ./apps/api/data/secrets/install.env
