name: adapter-1c-mcp

services:
  adapter-1c-mcp:
    build:
      context: ../../../../plugins/1c/mcp
      dockerfile: Dockerfile
    image: ${ADAPTER_1C_MCP_IMAGE:-adapter-1c-mcp:latest}
    container_name: ${ADAPTER_1C_MCP_CONTAINER_NAME:-adapter-1c-mcp}
    restart: unless-stopped
    ports:
      - "${ADAPTER_1C_MCP_HOST_PORT:-8021}:8021"
    environment:
      PORT: "8021"
      ONEC_ADAPTER_URL: ${ONEC_ADAPTER_URL:-http://docker.cin.su:8011}
      ONEC_ADAPTER_TOKEN: ${ONEC_ADAPTER_TOKEN:-}
      ONEC_ADAPTER_TIMEOUT_SECONDS: ${ONEC_ADAPTER_TIMEOUT_SECONDS:-240}
      ONEC_MCP_ALLOW_DIAGNOSTIC: ${ONEC_MCP_ALLOW_DIAGNOSTIC:-false}
      ONEC_MCP_DEBUG_DIAGNOSTICS: ${ONEC_MCP_DEBUG_DIAGNOSTICS:-false}
    volumes:
      - adapter-1c-mcp-data:/data

  adapter-1c-mcp-audit:
    image: ${ADAPTER_1C_MCP_IMAGE:-adapter-1c-mcp:latest}
    container_name: ${ADAPTER_1C_MCP_AUDIT_CONTAINER_NAME:-adapter-1c-mcp-audit}
    restart: unless-stopped
    depends_on:
      - adapter-1c-mcp
    volumes:
      - adapter-1c-mcp-data:/data
    environment:
      ONEC_MCP_AUDIT_INTERVAL_SECONDS: ${ONEC_MCP_AUDIT_INTERVAL_SECONDS:-900}
    command: >-
      sh -c 'mkdir -p /data/adapter-audit-reports;
      while true; do python /app/analyze_audit.py > /data/adapter-audit-reports/latest.json.tmp
      && mv /data/adapter-audit-reports/latest.json.tmp /data/adapter-audit-reports/latest.json;
      sleep "$${ONEC_MCP_AUDIT_INTERVAL_SECONDS}"; done'

volumes:
  adapter-1c-mcp-data:
