services: ha-mcp-server: build: context: . dockerfile: Dockerfile image: ha-mcp-server:latest container_name: ha-mcp-server # Environment variables for Home Assistant connection environment: - HA_BASE_URL=${HA_BASE_URL:-http://homeassistant.local:8123} - HA_ACCESS_TOKEN=${HA_ACCESS_TOKEN} - NODE_ENV=production # Use host network mode to access Home Assistant on local network # Alternative: Use bridge network if HA is also in Docker network_mode: host # Restart policy - "no" is appropriate for stdio MCP servers # MCP servers are started on-demand by clients, not long-running services restart: "no" # Security options security_opt: - no-new-privileges:true # Read-only root filesystem for security (app writes to /tmp only) read_only: true tmpfs: - /tmp # Resource limits deploy: resources: limits: cpus: '0.5' memory: 256M reservations: cpus: '0.1' memory: 64M # Logging configuration logging: driver: json-file options: max-size: "10m" max-file: "3" # Health check disabled for stdio-based MCP servers # MCP servers communicate via stdin/stdout, which conflicts with healthchecks healthcheck: disable: true # Alternative configuration for bridge network with HA in Docker # Uncomment if your Home Assistant is also running in Docker # # networks: # ha-network: # driver: bridge # # services: # ha-mcp-server: # networks: # - ha-network # # Remove network_mode: host when using bridge network