version: '3.8'

services:
  listmonk-mcp:
    build: .
    container_name: listmonk-mcp-server
    restart: unless-stopped
    environment:
      - LISTMONK_BASE_URL=${LISTMONK_BASE_URL:-http://listmonk:9000/api}
      - LISTMONK_USERNAME=${LISTMONK_USERNAME:-admin}
      - LISTMONK_PASSWORD=${LISTMONK_PASSWORD:-changeme}
      - LISTMONK_API_KEY=${LISTMONK_API_KEY:-}
      - NODE_ENV=production
    networks:
      - mcp-network
    stdin_open: true
    tty: true
    healthcheck:
      test: ["CMD", "node", "-e", "console.log('Health check OK')"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 5s
    labels:
      - "mcp.service=listmonk-mcp-server"
      - "mcp.type=email-marketing"
      - "mcp.description=ListMonk email marketing automation via MCP"
      - "mcp.port=stdio"
      - "mcp.remote_access=via-sse-bridge"

  listmonk-sse-bridge:
    build: .
    container_name: listmonk-sse-bridge
    restart: unless-stopped
    command: ["node", "listmonk-sse-bridge.cjs"]
    environment:
      - LISTMONK_BASE_URL=${LISTMONK_BASE_URL:-http://listmonk:9000/api}
      - LISTMONK_USERNAME=${LISTMONK_USERNAME:-admin}
      - LISTMONK_PASSWORD=${LISTMONK_PASSWORD:-changeme}
      - LISTMONK_API_KEY=${LISTMONK_API_KEY:-}
      - PORT=9090
      - NODE_ENV=production
    ports:
      - "9888:9090"
    networks:
      - mcp-network
    depends_on:
      - listmonk-mcp
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:9090/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
    labels:
      - "mcp.service=listmonk-sse-bridge"
      - "mcp.type=email-marketing-bridge"
      - "mcp.description=SSE bridge for remote ListMonk MCP access"
      - "mcp.port=9090"
      - "mcp.endpoints=sse,mcp,health,info"

networks:
  mcp-network:
    external: true