name: svacer-13

services:
  postgresql:
    image: postgres:17.0-bullseye
    container_name: svacer-13-postgres
    restart: always
    shm_size: 1g
    environment:
      - POSTGRES_DB=svace
      - POSTGRES_USER=svace
      - POSTGRES_PASSWORD=svace
    volumes:
      - svacer-postgres:/var/lib/postgresql/data
    networks:
      svacer:
    healthcheck:
      test: pg_isready -U svace
      interval: 10s

  postgresql-ai:
    image: postgres:17.0-bullseye
    container_name: svacer-13-ai-postgres
    profiles: [ai,llm]
    restart: always
    shm_size: 1g
    environment:
      - POSTGRES_DB=svacerai
      - POSTGRES_USER=svace
      - POSTGRES_PASSWORD=svace
    volumes:
      - svacerai-postgres:/var/lib/postgresql/data
    networks:
      svacer:
    healthcheck:
      test: pg_isready -U svace -d svacerai
      interval: 10s

  svacerai-model:
    image: ispras/svacerai-model:12-0-1
    container_name: svacer-13-ai-model
    profiles: [ai,llm]
    restart: always
    networks:
      svacer:

  svacerai-server:
    image: ispras/svacerai:13-alpha
    container_name: svacer-13-ai-server
    profiles: [ai,llm]
    restart: always
    init: true
    depends_on:
      postgresql-ai:
        condition: service_healthy
    environment:
      - DEBUG=false
      - SVACERAI_PG_URL=postgres://svace:svace@postgresql-ai:5432/svacerai?sslmode=disable
      - HOST=0.0.0.0:7001
      - AI_HOST=server-status:http://svacerai-model:8000/
      - SVACER_HOST=http://svacer:8080
      - SVACER_AI_AI_HOSTS_DEFAULTS_VALIDATION_MAXATTEMPTS=${MODEL_VALIDATION_MAXATTEMPTS:-12}
    networks:
      svacer:

  svacer:
    image: ispras/svacer:13-alpha
    container_name: svacer-13
    restart: always
    shm_size: 1g
    init: true
    depends_on:
      postgresql:
        condition: service_healthy
    ports:
      - 3002:3002
      - 8080:8080
      # uncomment next line to map profiler port (if enabled in env var below)
      # - 6060:6060
    environment:
      - DEBUG=false
      # uncomment next line to enable profiler on the speficied port
      # map it above in the 'ports' section and profiler will be available at http://localhost:6060/api/debug/pprof/
      # - PPROF_PORT=6060

      - SVACER_PG_URL=postgres://svace:svace@postgresql:5432/svace?pool_max_conns=20
      - STORE=/data/store

      - AIASSISTANT_ENABLE=true
      - XSVACER_AIASSISTANT_ASSISTANTHOSTURL=http://svacerai-server:7001/      

      # set public URL (required for notifications and for short URLs generation)
      # - PUBLIC_URL=http://svacer.intra.net:8080

      # mount LDAP config as a volume and set path to it to enable LDAP auth
      # - LDAP_CONFIG=/svacer/bin/ldap.conf

      # enable WebIDE; requires mounting /var/run/docker.sock as a volume
      # see https://svacer.ispras.ru/mediawiki/index.php?title=Help:XSvacer:Webide
      - WEBIDE_ENABLE=true
    volumes:
      - svacer-object-store:/data/store

      # for advanced configuration you may create config file and mount it as a volume to the default config path
      # - ./svacer.cfg:/svacer/bin/svacer.cfg

      # mount LDAP config and set path to it in ENV var 'LDAP_CONFIG' to enable LDAP auth
      # - ./ldap.conf:/svacer/bin/ldap.conf

      # required for WebIDE, see https://svacer.ispras.ru/mediawiki/index.php?title=Help:XSvacer:Webide
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - svacer-snapshot-sources:/root/.cache/svacer-snapshot-sources
    networks:
      svacer:

  svacer-validation-server:
    image: ispras/validation-server:13-alpha
    container_name: svacer-13-validation-server
    profiles: [llm]
    restart: unless-stopped
    depends_on:
      svacer:
        condition: service_healthy
    environment:
      - LLM_URL=${LLM_URL} 
      - LLM_TOKEN=${LLM_TOKEN}
      - SVACER_URL=${SVACER_URL:-http://svacer:8080}
      - REG_URL=${REG_URL:-http://svacer-validation-server:5000}
      - REG_TOKEN=${REG_TOKEN:-}
      - REG_LOGIN=${REG_LOGIN:-admin}
      - REG_PASSWORD=${REG_PASSWORD:-admin} 
      - REG_ID=${REG_ID:-llm}
      - REG_NAME=${REG_NAME:-llm}
      - REG_DESCRIPTION=${REG_DESCRIPTION:-"LLM model service"}
      - MODEL_WHITELIST=${MODEL_WHITELIST:-}
      - MAX_PARALLEL_REQUESTS=${MAX_PARALLEL_REQUESTS:-1}
    command: --host 0.0.0.0
    networks:
      svacer:

  svacer-mcp:
    image: ispras/svacer-mcp:13-alpha
    container_name: svacer-13-mcp
    profiles: [mcp]
    restart: unless-stopped
    depends_on:
      svacer:
        condition: service_healthy
    environment:
      - SVACER_TRANSPORT=http
      - SVACER_URL=http://svacer:8080
      - SVACER_LOGIN=${SVACER_LOGIN:-admin}
      - SVACER_PASSWORD=${SVACER_PASSWORD:-admin}
      - SVACER_TIMEOUT=${SVACER_TIMEOUT:-30}
      - SVACER_MCP_TOKEN=${SVACER_MCP_TOKEN} 
      - SVACER_MCP_RESOURCE_URL=${SVACER_MCP_RESOURCE_URL:-}
      - MCP_ENABLE_DNS_REBINDING_PROTECTION=${MCP_ENABLE_DNS_REBINDING_PROTECTION:-true}
      - MCP_ALLOWED_HOSTS=${MCP_ALLOWED_HOSTS:-svacer-mcp:*}
      - MCP_ALLOWED_ORIGINS=${MCP_ALLOWED_ORIGINS:-http://svacer-mcp:*}
    ports:
      - "${MCP_PORT:-8002}:8000"
    networks:
      svacer:

volumes:
  svacer-postgres:
    name: svacer-13-postgres
  svacerai-postgres:
    name: svacer-13-ai-postgres
  svacer-object-store:
    name: svacer-13-object-store
  svacer-snapshot-sources:
    name: svacer-13-snapshot-sources

networks:
  svacer:
    name: svacer-13
