Files
mcp-maigret/docker-compose.yml
Hermes Agent 8e6dd3174a
CI / Build on Node 18 (push) Canceled after 0s
CI / Build on Node 20 (push) Canceled after 0s
CI / Build on Node 22 (push) Canceled after 0s
CI / Docker image builds (push) Canceled after 0s
Move the gateway to port 8080: 8000 belongs to Gluetun's control server
The container crash-looped with EADDRINUSE: address already in use
0.0.0.0:8000. Gluetun runs its own HTTP control server on 8000 and the app
shares Gluetun's network namespace, so the port was already bound before
supergateway started. Nothing was wrong with the app, the image or the flags —
the deploy log shows every supergateway option applied correctly.

Also notes that 127.0.0.1:53 and 127.0.0.1:9999 are taken in the same namespace,
and lists the four places that must change together if the port moves again.

Co-located containers share one port space: enumerate the sidecar's listeners,
not just the app's.
2026-11-21 11:43:08 +00:00

157 lines
7.2 KiB
YAML

# mcp-maigret behind a Surfshark WireGuard tunnel, published over HTTPS.
#
# Shape of this stack:
# gluetun owns the network namespace and the tunnel (Surfshark, WireGuard)
# maigret-mcp runs INSIDE that namespace and is the only service with a listener
#
# Why the gateway: mcp-maigret speaks stdio only (StdioServerTransport, see
# src/index.ts). It has no HTTP listener, so the Dockerfile's EXPOSE 3000 is
# decorative. supergateway is baked into the image and wraps the stdio server as
# Streamable HTTP on :8080/mcp — that is what the domain points at.
#
# Port 8080, NOT 8000: Gluetun runs its own HTTP control server on 8000, and the
# app shares Gluetun's network namespace, so 8000 is already bound before this
# container starts (symptom: `EADDRINUSE: address already in use 0.0.0.0:8000`).
# Gluetun also holds 127.0.0.1:53 (DNS) and 127.0.0.1:9999 (health server) in the
# same namespace — do not reuse those either.
#
# Egress: every request the server makes to the hundreds of sites maigret checks
# leaves through Surfshark, because the whole container lives in gluetun's netns.
services:
gluetun:
image: qmcgaw/gluetun:v3.41.3
# Pinned to the last STABLE release (2026-07-30). Do not switch to :latest —
# :latest currently resolves to an untagged edge build (created 2026-11-20,
# revision eb3c7ec7) that is not a published version. v3 / v3.41 / v3.41.3 all
# resolve to the same digest, so the full version is written out.
restart: unless-stopped
cap_add:
- NET_ADMIN # Gluetun manipulates iptables and the tun device
devices:
- /dev/net/tun:/dev/net/tun # WireGuard tun interface
environment:
VPN_SERVICE_PROVIDER: surfshark
VPN_TYPE: wireguard
# Surfshark WireGuard needs a REGISTERED KEYPAIR, not account credentials.
# Surfshark > VPN > Manual setup > Desktop or mobile > WireGuard >
# "I don't have a keypair" > Generate a new keypair, then download any
# location's config:
# WIREGUARD_PRIVATE_KEY <- "Private key" line
# WIREGUARD_ADDRESSES <- "Address" line, IPv4 part (e.g. 10.14.0.2/16)
# The ":?" form fails the deploy loudly instead of starting a tunnel-less
# container. Declaring each variable as its own key is what makes Coolify
# show an editable field for it.
WIREGUARD_PRIVATE_KEY: "${WIREGUARD_PRIVATE_KEY:?set your Surfshark WireGuard private key}"
WIREGUARD_ADDRESSES: "${WIREGUARD_ADDRESSES:?set the Address line of your Surfshark WireGuard config, e.g. 10.14.0.2/16}"
SERVER_COUNTRIES: "${SERVER_COUNTRIES:-Austria}"
TZ: "${TZ:-Europe/Vienna}"
# The reverse proxy reaches the gateway through gluetun's own interface on
# the compose network Coolify attaches. Gluetun already accepts input from
# subnets it is attached to, so this is a belt-and-braces default rather
# than a requirement; drop it if you prefer the narrower rule.
FIREWALL_INPUT_PORTS: "8080"
# Seeds a domain row in the UI. The Domains field is authoritative — this
# value is only a path, it cannot set the hostname. See DEPLOY.md §3.
SERVICE_URL_GLUETUN_8080: "/"
healthcheck:
# Gluetun's own readiness probe, exactly as its Dockerfile declares it. This
# is the ONLY correct "tunnel is up" signal — the app waits on it, so nothing
# egresses before the tunnel exists.
test: ["CMD", "/gluetun-entrypoint", "healthcheck"]
interval: 30s
timeout: 10s
retries: 5
start_period: 45s
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
maigret-mcp:
# No image is published for this project (Docker Hub 404, GHCR 403), so it is
# built from the repo's own Dockerfile — which is why this needs a Git checkout
# and cannot be pasted into a "Docker Compose Empty" resource.
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
# --- The VPN wiring -------------------------------------------------------
# The app joins Gluetun's network namespace: no networks:, no ports:. Anything
# it dials goes out through Surfshark.
network_mode: "service:gluetun"
depends_on:
gluetun:
condition: service_healthy
# The image's ENTRYPOINT is ["node", "build/index.js"], and `command:` only
# replaces CMD — it would be APPENDED to that node call and the gateway would
# never start. So entrypoint is overridden and the stdio server is handed to
# supergateway as its child instead.
entrypoint: ["supergateway"]
command:
- "--stdio"
- "node build/index.js"
- "--outputTransport"
- "streamableHttp"
- "--host"
- "0.0.0.0" # not 127.0.0.1: the proxy connects from outside the netns
- "--port"
- "8080" # 8000 belongs to Gluetun's control server in this netns
- "--streamableHttpPath"
- "/mcp"
# Open, unauthenticated liveness endpoint for the container healthcheck.
- "--healthEndpoint"
- "/healthz"
# "server" (not the default "gateway") makes /healthz actually start the MCP
# server, initialize and ping it, so a broken child reports 503.
- "--healthCheck"
- "server"
# supergateway documents that it exits when its stdin closes. It survived a
# /dev/null stdin in testing, but an open stdin costs nothing — and it is what
# the bare stdio server needs if you ever drop the gateway (with /dev/null the
# server exits 0 immediately and exit-loops under restart: unless-stopped).
stdin_open: true
init: true # reaps the python/maigret children the server spawns
environment:
# Required by the server: it throws at startup if this is unset.
MAIGRET_REPORTS_DIR: /app/reports
# MANDATORY for VPN egress. "local" runs the maigret bundled in the image
# (venv at /opt/maigret). NEVER use MAIGRET_RUNNER=docker here: that path
# shells out to `docker run`, which would create a SIBLING container on the
# default bridge — outside this namespace, egressing from the host IP and
# silently defeating the VPN.
MAIGRET_RUNNER: local
TZ: "${TZ:-Europe/Vienna}"
# Bearer token for the public endpoint; supergateway answers 401 without it.
# Coolify generates and stores this (64 chars, no symbols). For a local
# `docker compose up`, set SERVICE_PASSWORD_64_MCPAPIKEY in .env.
SUPERGATEWAY_API_KEY: "${SERVICE_PASSWORD_64_MCPAPIKEY:?API key for the public MCP endpoint}"
volumes:
- maigret-reports:/app/reports
healthcheck:
# /healthz is the one path exempt from the API key. node is already in the
# image, so no curl/wget is needed (node:24-slim ships neither).
test:
- CMD-SHELL
- >-
node -e "fetch('http://127.0.0.1:8080/healthz').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
interval: 60s
timeout: 20s
retries: 3
start_period: 60s
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
volumes:
maigret-reports:
# Named explicitly so a rebuilt/redeployed stack keeps its saved reports.
name: maigret-reports