services:
  db:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: ai_control_chat_ui
      POSTGRES_USER: ai-control-chat-ui
      POSTGRES_PASSWORD: ai-control-chat-ui
    ports:
      - "5433:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ai-control-chat-ui -d ai_control_chat_ui"]
      interval: 5s
      timeout: 5s
      retries: 12

  app:
    build: .
    ports:
      - "3000:3000"
    environment:
      DATABASE_URL: postgresql://ai-control-chat-ui:ai-control-chat-ui@db:5432/ai_control_chat_ui
      JWT_SECRET: local-development-secret-change-before-production
      JWT_ISSUER: corp-ui
      JWT_AUDIENCE: aegida-gate
      AEGIDA_TENANT_ID: tenant-1
      AEGIDA_GATE_URL: http://host.docker.internal:8082
      AUTH_USER_ID: 00000000-0000-4000-8000-000000000001
      AUTH_EMAIL: demo@ai-control.local
      AUTH_PASSWORD: Demo1234!
      AUTH_SEED_ENABLED: "false"
      NEXT_PUBLIC_APP_URL: http://localhost:3000
      USER_SERVICE_URL: http://host.docker.internal:8080
      S3_ENDPOINT: http://minio:9000
      S3_REGION: us-east-1
      S3_BUCKET: ai-control-chat-attachments
      S3_ACCESS_KEY_ID: ai-control-chat-ui
      S3_SECRET_ACCESS_KEY: ai-control-chat-ui
      S3_FORCE_PATH_STYLE: "true"
    depends_on:
      db:
        condition: service_healthy
      minio:
        condition: service_started
    extra_hosts:
      - "host.docker.internal:host-gateway"

  minio:
    image: minio/minio:RELEASE.2025-04-22T22-12-26Z
    command: server /data --console-address ":9001"
    environment:
      MINIO_ROOT_USER: ai-control-chat-ui
      MINIO_ROOT_PASSWORD: ai-control-chat-ui
    ports:
      - "9000:9000"
      - "9001:9001"
    volumes:
      - minio_data:/data

volumes:
  postgres_data:
  minio_data:
