version: '3.8'

# MCP ABAP ADT Server using npm package tarball
#
# Before building:
# 1. Run 'npm pack' in project root
# 2. Move .tgz to docker/packages/
#
# Usage: docker-compose -f docker-compose.package.yml up -d

services:
  mcp-abap-adt:
    build:
      context: ..
      dockerfile: docker/Dockerfile.package
    image: mcp-abap-adt:package
    container_name: mcp-abap-adt-server
    restart: unless-stopped

    # HTTP transport for client connections
    ports:
      - "3000:3000"

    # Environment configuration
    environment:
      - NODE_ENV=production
      - MCP_HTTP_PORT=3000
      - MCP_HTTP_HOST=0.0.0.0

      # Destination name (service key filename without .json)
      - MCP_DESTINATION=${MCP_DESTINATION:-default}

    # Volumes for AuthBroker data
    volumes:
      # Service keys directory - put your {destination}.json files here
      - ./service-keys:/app/service-keys:ro

    # Resource limits
    deploy:
      resources:
        limits:
          cpus: '1.0'
          memory: 1G
        reservations:
          cpus: '0.5'
          memory: 512M

    # Healthcheck
    healthcheck:
      test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 10s

    # Logging
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"
