# Isolated containers - one per connection
# Better resource isolation, recommended for production or multi-user servers
# Router on 5200, connections on 5210+
#
# Shared config defined once via x-connection-defaults anchor.
# Each connection service merges it with <<: *connection-defaults.
#
# SETUP: Copy this file and replace the example connection names
# with your actual connection names from ~/.m365-connections.json.
# Add more services by copying the pattern (increment port numbers).
#
# Usage:
# docker compose -p m365-session-pool -f docker-compose.isolated.yml up -d
x-connection-defaults: &connection-defaults
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
networks:
- m365-network
deploy:
resources:
limits:
cpus: "0.5"
memory: 512M
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5200/health"]
interval: 60s
timeout: 10s
retries: 3
start_period: 60s
x-connection-volumes: &connection-volumes
- ~/.m365-connections.json:/root/.m365-connections.json:ro
- ~/.m365-logs:/app/logs
- ~/.m365-state:/app/state
services:
router:
build:
context: .
dockerfile: Dockerfile.router
container_name: m365-router
restart: unless-stopped
ports:
- "5200:5200"
environment:
- ROUTER_HOST=0.0.0.0
- ROUTER_PORT=5200
volumes:
- ~/.m365-connections.json:/root/.m365-connections.json:ro
- /var/run/docker.sock:/var/run/docker.sock
networks:
- m365-network
deploy:
resources:
limits:
cpus: "0.25"
memory: 128M
depends_on:
- contoso-ga
- contoso-individual
# --- Example connection: Contoso Global Admin ---
contoso-ga:
<<: *connection-defaults
container_name: m365-contoso-ga
ports:
- "5210:5200"
environment:
- M365_CONNECTION=Contoso-GA # Must match name in ~/.m365-connections.json
- M365_POOL_PORT=5200
volumes:
- ~/.m365-connections.json:/root/.m365-connections.json:ro
- ~/.m365-logs:/app/logs
- ~/.m365-state:/app/state
- m365-contoso-ga-azure:/root/.Azure
- m365-contoso-ga-config:/root/.config
- m365-contoso-ga-local:/root/.local
# --- Example connection: Contoso Individual ---
contoso-individual:
<<: *connection-defaults
container_name: m365-contoso-individual
ports:
- "5211:5200"
environment:
- M365_CONNECTION=Contoso-Individual # Must match name in ~/.m365-connections.json
- M365_POOL_PORT=5200
volumes:
- ~/.m365-connections.json:/root/.m365-connections.json:ro
- ~/.m365-logs:/app/logs
- ~/.m365-state:/app/state
- m365-contoso-individual-azure:/root/.Azure
- m365-contoso-individual-config:/root/.config
- m365-contoso-individual-local:/root/.local
# Add more connections by copying the pattern above.
# Increment the port number (5212, 5213, ...) for each.
networks:
m365-network:
driver: bridge
volumes:
m365-contoso-ga-azure:
m365-contoso-ga-config:
m365-contoso-ga-local:
m365-contoso-individual-azure:
m365-contoso-individual-config:
m365-contoso-individual-local: