# docker-compose for dms-api sidecar.
# Run on the same host as the `mailserver` container.

services:
  dms-api:
    build: .
    image: dms-api:latest
    container_name: dms-api
    restart: unless-stopped
    init: true
    environment:
      DMS_CONTAINER: "mailserver"
      DMS_API_TOKEN: "${DMS_API_TOKEN:?DMS_API_TOKEN must be set in env or .env}"
      DMS_API_BIND: "127.0.0.1"
      DMS_API_PORT: "8791"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    # Internal-only — front with caddy/nginx + LE for HTTPS.
    expose:
      - "8791"
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://127.0.0.1:8791/health"]
      interval: 30s
      timeout: 5s
      retries: 3
