|
| 1 | +# contrib/docker-compose.example.yml |
| 2 | +# |
| 3 | +# Example Docker Compose setup for running MCP servers in containers on a Mac |
| 4 | +# host while botlockbox provides credential injection from the host. |
| 5 | +# |
| 6 | +# Prerequisites: |
| 7 | +# 1. botlockbox is running on the Mac host via launchd (Mode 1 — Secure Enclave). |
| 8 | +# 2. botlockbox.yaml uses listen: "0.0.0.0:8080" (NOT 127.0.0.1). |
| 9 | +# Without this, Docker containers cannot reach the proxy. |
| 10 | +# 3. The CA cert has been written to ~/.botlockbox/ca.pem via |
| 11 | +# --ca-cert ~/.botlockbox/ca.pem in the launchd plist. |
| 12 | +# |
| 13 | +# Usage: |
| 14 | +# docker compose -f contrib/docker-compose.example.yml up |
| 15 | +# |
| 16 | +# No credentials are placed in any container. |
| 17 | +# botlockbox on the Mac host injects Authorization / API headers |
| 18 | +# transparently before forwarding requests to external APIs. |
| 19 | + |
| 20 | +# ────────────────────────────────────────────────────────────────────────────── |
| 21 | +# Reusable YAML anchors — merge these into any service's environment block. |
| 22 | +# ────────────────────────────────────────────────────────────────────────────── |
| 23 | + |
| 24 | +x-botlockbox-proxy: &botlockbox-proxy |
| 25 | + # Route all HTTP/HTTPS traffic through botlockbox on the Mac host. |
| 26 | + # Docker Desktop resolves host.docker.internal to the host IP automatically. |
| 27 | + HTTP_PROXY: "http://host.docker.internal:8080" |
| 28 | + HTTPS_PROXY: "http://host.docker.internal:8080" |
| 29 | + http_proxy: "http://host.docker.internal:8080" |
| 30 | + https_proxy: "http://host.docker.internal:8080" |
| 31 | + # Keep container-local and LAN traffic off the proxy. |
| 32 | + NO_PROXY: "localhost,127.0.0.1,*.local" |
| 33 | + |
| 34 | +x-botlockbox-ca: &botlockbox-ca |
| 35 | + # Trust the botlockbox ephemeral MITM CA for each language runtime. |
| 36 | + # All point at the same mounted PEM — no code changes or image rebuilds needed. |
| 37 | + REQUESTS_CA_BUNDLE: /etc/botlockbox/ca.pem # Python: requests, httpx, boto3, openai-sdk |
| 38 | + NODE_EXTRA_CA_CERTS: /etc/botlockbox/ca.pem # Node.js: all https / fetch |
| 39 | + SSL_CERT_FILE: /etc/botlockbox/ca.pem # Go stdlib, Ruby net/http |
| 40 | + CURL_CA_BUNDLE: /etc/botlockbox/ca.pem # curl, libcurl (many CLIs) |
| 41 | + |
| 42 | +services: |
| 43 | + # ────────────────────────────────────────────────────────────────────────── |
| 44 | + # Replace this with your actual MCP server image. |
| 45 | + # The only required additions are the environment and volumes blocks below. |
| 46 | + # ────────────────────────────────────────────────────────────────────────── |
| 47 | + mcp-server: |
| 48 | + image: your-mcp-server-image:latest |
| 49 | + environment: |
| 50 | + <<: [*botlockbox-proxy, *botlockbox-ca] |
| 51 | + # Your MCP server's own non-secret config goes here. |
| 52 | + # API keys / tokens are NOT needed — botlockbox injects them. |
| 53 | + # MCP_SERVER_PORT: "3000" |
| 54 | + volumes: |
| 55 | + # Mount the botlockbox CA cert from the Mac host (read-only). |
| 56 | + - "${HOME}/.botlockbox/ca.pem:/etc/botlockbox/ca.pem:ro" |
| 57 | + extra_hosts: |
| 58 | + # Ensures host.docker.internal resolves on Linux Docker hosts too. |
| 59 | + # Ignored (harmless) on Docker Desktop for Mac. |
| 60 | + - "host.docker.internal:host-gateway" |
| 61 | + |
| 62 | + # ────────────────────────────────────────────────────────────────────────── |
| 63 | + # Second service example: a Python-based MCP server. |
| 64 | + # Add as many services as needed; each gets the same proxy + CA config. |
| 65 | + # ────────────────────────────────────────────────────────────────────────── |
| 66 | + mcp-fetch: |
| 67 | + image: ghcr.io/modelcontextprotocol/mcp-server-fetch:latest |
| 68 | + environment: |
| 69 | + <<: [*botlockbox-proxy, *botlockbox-ca] |
| 70 | + volumes: |
| 71 | + - "${HOME}/.botlockbox/ca.pem:/etc/botlockbox/ca.pem:ro" |
| 72 | + extra_hosts: |
| 73 | + - "host.docker.internal:host-gateway" |
0 commit comments