Docker Deployment

Docker Deployment

Deploy LeafMesh applications using Docker containers.

Dockerfile

FROM python:3.11-slim WORKDIR /app # Install dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application COPY app.py . COPY intelligence/ ./intelligence/ COPY tools/ ./tools/ # Expose API port EXPOSE 18820 CMD ["python", "app.py"]

requirements.txt

leafmesh>=2.4.509
aiohttp>=3.8.0
redis>=4.5.0
pydantic>=2.0.0
apscheduler>=3.10.0
fastapi>=0.100.0
uvicorn>=0.22.0
pyyaml>=6.0

Docker Compose

Run the application with Redis:

version: "3.8" services: redis: image: redis:7-alpine ports: - "6379:6379" volumes: - redis_data:/data command: redis-server --appendonly yes app: build: . ports: - "18820:18820" environment: - LEAFMESH_STORE=redis - REDIS_HOST=redis - REDIS_PORT=6379 - OPENAI_API_KEY=${OPENAI_API_KEY} - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} depends_on: - redis volumes: redis_data:

Configuration for Docker

From 2.4.482 the store is set only through environment variables (.env or the container's environment:), never in the YAML. Leave persistence: and redis: out of config.yaml; an older file that still has them gets a warning at boot and the block is ignored.

The environment: entries in the compose file above are all LeafMesh needs to find Redis. For a password-protected or TLS Redis, or for Postgres, add the matching variables:

# .env LEAFMESH_AGENCY_NAME=my-agency LEAFMESH_STORE=redis REDIS_HOST=redis REDIS_PORT=6379 REDIS_PASSWORD=your-password REDIS_SSL=true REDIS_SSL_CA_CERTS=/etc/ssl/certs/redis-ca.crt # Or name the whole server in one URL (rediss:// turns TLS on): # REDIS_URL=redis://user:pw@redis:6379/0 # Or, for Postgres: # LEAFMESH_STORE=postgres # DATABASE_URL=postgresql://user:pw@postgres:5432/leafmesh?sslmode=require # ...or the single names: # POSTGRES_HOST=postgres # POSTGRES_PORT=5432 # POSTGRES_DB=leafmesh # POSTGRES_USER=leafmesh # POSTGRES_PASSWORD=your-password

The full list is on Persistence. Once the container is up, Studio shows whether the store is reachable under Infrastructure → Datastores, which also shows its latency, the server, the settings in force and which .env names set them — never the address or password.

Building and Running

# Build the image docker build -t my-swarm-app . # Run with Docker Compose docker compose up -d # Check logs docker compose logs -f app # Stop docker compose down

Multi-Instance Deployment

Run multiple LeafMesh instances behind a load balancer:

version: "3.8" services: redis: image: redis:7-alpine ports: - "6379:6379" app: build: . deploy: replicas: 3 environment: - LEAFMESH_STORE=redis - REDIS_HOST=redis - OPENAI_API_KEY=${OPENAI_API_KEY} depends_on: - redis nginx: image: nginx:alpine ports: - "80:80" volumes: - ./nginx.conf:/etc/nginx/nginx.conf depends_on: - app

Health Check

Add a health check to your Docker configuration:

services: app: build: . healthcheck: test: ["CMD", "curl", "-f", "http://localhost:18820/health"] interval: 30s timeout: 10s retries: 3 start_period: 10s

Next Steps


LeafMesh — Docker container deployment

Last updated: 11/10/2026