
# Multi-User Mode - Add collaboration features
# Usage: docker-compose -f infrastructure/docker/docker-compose.yaml -f infrastructure/docker/docker-compose.multi-user.yaml up

services:
  orchestrator:
    environment:
      - PROVISIONING_MODE=multi-user
      - ORCHESTRATOR_MAX_CONCURRENT_TASKS=10
      - ORCHESTRATOR_AUTH_ENABLED=true
    deploy:
      resources:
        limits:
          cpus: '2.0'
          memory: 2048M

  control-center:
    environment:
      - PROVISIONING_MODE=multi-user
      - CONTROL_CENTER_AUTH_REQUIRED=true
      - CONTROL_CENTER_MULTI_USER=true
      - CONTROL_CENTER_SESSION_MANAGEMENT=true
    deploy:
      resources:
        limits:
          cpus: '1.0'
          memory: 1024M

  # Enable Gitea for source control
  gitea:
    profiles:
      - multi-user
    environment:
      - GITEA__service__DISABLE_REGISTRATION=${GITEA_DISABLE_REGISTRATION:-false}
      - GITEA__service__REQUIRE_SIGNIN_VIEW=${GITEA_REQUIRE_SIGNIN:-false}
      - GITEA__repository__ENABLE_PUSH_CREATE_USER=true
    deploy:
      resources:
        limits:
          cpus: '${GITEA_CPU_LIMIT:-1000m}'
          memory: ${GITEA_MEMORY_LIMIT:-1024M}

  # Enable PostgreSQL for shared database
  postgres:
    profiles:
      - multi-user
    image: postgres:16-alpine
    container_name: provisioning-postgres
    environment:
      - POSTGRES_DB=${POSTGRES_DB:-provisioning}
      - POSTGRES_USER=${POSTGRES_USER:-provisioning}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
    volumes:
      - postgres-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-provisioning}"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped
    networks:
      - provisioning-net-backend
    deploy:
      resources:
        limits:
          cpus: '${POSTGRES_CPU_LIMIT:-2000m}'
          memory: ${POSTGRES_MEMORY_LIMIT:-2048M}

  # Update OCI registry with authentication
  oci-registry:
    environment:
      - ZOT_AUTH_ENABLED=true
      - ZOT_EXTENSIONS_SYNC=true
      - ZOT_EXTENSIONS_SEARCH=true
    volumes:
      - ../oci-registry/htpasswd:/etc/zot/htpasswd:ro
    deploy:
      resources:
        limits:
          cpus: '1.0'
          memory: 1024M

  extension-registry:
    environment:
      - PROVISIONING_MODE=multi-user
      - AUTH_REQUIRED=true
      - USER_MANAGEMENT_ENABLED=true
    depends_on:
      postgres:
        condition: service_healthy
    deploy:
      resources:
        limits:
          cpus: '0.5'
          memory: 512M

volumes:
  postgres-data:
    driver: local
