Docker Compose Setup
Purpose and Scope
This document describes the Docker Compose orchestration configuration that manages all Automatos AI services in a unified environment. It covers service definitions, networking, volume management, health checks, and development workflows.
For individual Dockerfile details and multi-stage build strategies, see Docker Containerization. For environment variable configuration, see Environment Variables. For database initialization and migrations, see Database Setup. For Redis configuration and caching policies, see Redis Configuration.
Sources: docker-compose.yml:1-198, README.md:52-78
Service Architecture
The Docker Compose configuration orchestrates four core services and optional admin tools using a single network and persistent volumes.
Service Summary
postgres
pgvector/pgvector:pg16
5432
default
PostgreSQL database with vector extension
redis
redis:7-alpine
6379
default
Cache, session store, and Pub/Sub
backend
Built from ./orchestrator
8000
default
FastAPI application server
frontend
Built from ./frontend
3000
default
Next.js web application
adminer
adminer:latest
8080
all
Database management UI
Sources: docker-compose.yml:17-174
Core Services Configuration
PostgreSQL Database
The postgres service runs PostgreSQL 16 with the pgvector extension for vector similarity search.
Configuration Details:
Container Name:
automatos_postgresRestart Policy:
unless-stoppedPort Mapping:
${POSTGRES_PORT:-5432}:5432Initialization: Mounts orchestrator/database/init_complete_schema.sql:1-* as
/docker-entrypoint-initdb.d/01-schema.sqlConnection Limits:
max_connections=200,shared_buffers=256MBHealth Check:
pg_isreadyevery 10 seconds, 5 retries, 10s start period
Environment Variables:
POSTGRES_DB
orchestrator_db
Database name
POSTGRES_USER
postgres
Database user
POSTGRES_PASSWORD
automatos_dev_pass
Database password
Sources: docker-compose.yml:21-42
Redis Cache
The redis service provides caching, session storage, and real-time Pub/Sub messaging.
Configuration Details:
Container Name:
automatos_redisRestart Policy:
unless-stoppedPort Mapping:
${REDIS_PORT:-6379}:6379Memory Limit:
256mbwithallkeys-lruevictionAuthentication: Password-protected via
REDIS_PASSWORDHealth Check:
redis-cli pingwith password authentication every 10 seconds
Memory Policy: The allkeys-lru policy evicts least recently used keys when the 256MB limit is reached, ensuring cache performance. The RedisClient class in orchestrator/core/redis/client.py:14-198 manages connections with a pool of up to 50 connections.
Sources: docker-compose.yml:47-63, orchestrator/core/redis/client.py:14-31
Backend Service
The backend service builds the FastAPI application from the orchestrator directory using the development target.
Build Configuration:
Context:
./orchestratorDockerfile: orchestrator/Dockerfile:1-116
Target Stage:
development(enables hot-reload)Base Image:
python:3.11-slim
Runtime Configuration:
Container Name:
automatos_backendPort Mapping:
${API_PORT:-8000}:8000Command:
uvicorn main:app --host 0.0.0.0 --port 8000 --reloadorchestrator/Dockerfile:71Restart Policy:
unless-stopped
Volume Mounts:
Source Code:
./orchestrator:/app- Enables hot-reload during developmentEntrypoint:
./docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh:ro- Database wait scriptLogs:
backend_logs:/app/logs- Persistent log storage
Dependencies:
The backend waits for both postgres and redis to report healthy status via their health checks before starting.
Health Check: curl -f http://localhost:8000/health every 30 seconds with 40-second start period.
Sources: docker-compose.yml:68-123, orchestrator/Dockerfile:45-71
Frontend Service
The frontend service builds the Next.js application using the development target for hot-reload.
Build Configuration:
Context:
./frontendDockerfile: frontend/Dockerfile:1-120
Target Stage:
developmentfrontend/Dockerfile:31-48Base Image:
node:20-alpine
Runtime Configuration:
Container Name:
automatos_frontendPort Mapping:
${FRONTEND_PORT:-3000}:3000Command:
npm run devfrontend/Dockerfile:48Node Environment:
development
Volume Mounts:
Source Code:
./frontend:/app- Enables hot-reloadNode Modules:
/app/node_modules(anonymous volume) - Prevents localnode_modulesfrom overwriting container'sNext.js Cache:
/app/.next(anonymous volume) - Prevents build cache conflicts
Dependency: Waits for backend service to be healthy before starting.
Health Check: wget --spider http://localhost:3000 every 30 seconds with 60-second start period frontend/Dockerfile:44-45.
Sources: docker-compose.yml:131-155, frontend/Dockerfile:31-48
Admin Tools Profile
Optional administrative tools are available via the all profile.
Adminer Database UI
The adminer service provides a web-based database management interface.
Configuration:
Image:
adminer:latestPort Mapping:
${ADMINER_PORT:-8080}:8080Profile:
all(not started by default)Default Server:
postgres(auto-connects to PostgreSQL service)Design Theme:
nette
Usage:
Login Credentials:
System:
PostgreSQLServer:
postgresUsername:
${POSTGRES_USER}Password:
${POSTGRES_PASSWORD}Database:
${POSTGRES_DB}
Sources: docker-compose.yml:161-174
Networking Configuration
All services connect to a single bridge network for service discovery.
Network Details:
Name:
automatos_networkDriver:
bridgeDNS Resolution: Each service is accessible by its service name (e.g.,
postgres,redis,backend)
Service Discovery Examples:
Backend connects to PostgreSQL:
postgres:5432docker-compose.yml:85-86Backend connects to Redis:
redis:6379docker-compose.yml:90-91Frontend API calls:
http://backend:8000(internal) or${NEXT_PUBLIC_API_URL}(external)
Sources: docker-compose.yml:193-196
Persistent Volumes
Three named volumes provide persistent storage across container restarts.
Volume Definitions
postgres_data
automatos_postgres_data
PostgreSQL database files
/var/lib/postgresql/data
redis_data
automatos_redis_data
Redis persistence files
/data
backend_logs
automatos_backend_logs
Backend application logs
/app/logs
Volume Management:
Sources: docker-compose.yml:179-188, docker-compose.yml:32-33, docker-compose.yml:54-55, docker-compose.yml:115
Health Checks and Dependency Management
Services use health checks to ensure proper startup order and readiness.
Health Check Configuration
PostgreSQL:
Redis:
Backend:
Frontend:
Dependency Chain
The depends_on configuration with condition: service_healthy ensures proper startup order:
postgresandredisstart independentlybackendwaits for both database and cache to be healthyfrontendwaits for backend to be healthyadminerwaits forpostgresto exist (no health condition)
Sources: docker-compose.yml:35-40, docker-compose.yml:56-61, docker-compose.yml:116-121, docker-compose.yml:44-45
Development vs Production Configuration
The compose file targets development, but both Dockerfiles support production builds.
Development Target (Current)
Backend Development Features:
All Python dependencies installed orchestrator/Dockerfile:33-35
Source code mounted from
./orchestratorto/appUvicorn with
--reloadflag orchestrator/Dockerfile:71Entrypoint script mounted for database wait logic
Frontend Development Features:
All npm dependencies including devDependencies frontend/Dockerfile:35
Source code mounted from
./frontendto/appNext.js dev server with hot module replacement frontend/Dockerfile:48
Anonymous volumes prevent
node_modulesconflicts
Production Target (Available)
To switch to production:
Production Optimizations:
Backend (orchestrator/Dockerfile:76-116):
Non-root user
automatos(UID 1000)Production dependencies only (
pip uninstall pytest)Multi-worker uvicorn (4 workers)
Environment-aware port binding (
${PORT:-8000})No source code mounting
Frontend (frontend/Dockerfile:85-118):
Non-root user
nextjs(UID 1001)Production dependencies only (
npm ci --only=production)Static build from
.nextdirectoryNo source code mounting
NODE_ENV=production
Sources: docker-compose.yml:68-155, orchestrator/Dockerfile:76-116, frontend/Dockerfile:85-118
Environment Variables
The compose file uses environment variable substitution with secure defaults.
Variable Priority
Shell environment (exported variables)
.envfile in project root (if present)Default values in
docker-compose.yml(e.g.,${POSTGRES_PASSWORD:-automatos_dev_pass})
Core Variables
POSTGRES_DB
orchestrator_db
postgres
Database name
POSTGRES_USER
postgres
postgres
Database user
POSTGRES_PASSWORD
automatos_dev_pass
postgres
Database password
POSTGRES_PORT
5432
postgres
Host port mapping
REDIS_PASSWORD
automatos_redis_dev
redis
Redis authentication
REDIS_PORT
6379
redis
Host port mapping
API_PORT
8000
backend
Backend host port
FRONTEND_PORT
3000
frontend
Frontend host port
NEXT_PUBLIC_API_URL
http://localhost:8000
frontend
Backend API endpoint
OPENAI_API_KEY
(empty)
backend
OpenAI API key (optional)
ANTHROPIC_API_KEY
(empty)
backend
Anthropic API key (optional)
Security Notes
No .env Required: The docker-compose.yml:9-10 header states "No .env file needed! Infrastructure uses secure defaults." This is intentional for quick starts - production deployments should override these defaults.
Credential Management: API keys for LLM providers are optional at startup. The UI provides a credentials management system (see Credentials Management) for adding keys after deployment.
Backend Authentication: The API_KEY variable (docker-compose.yml:103) defaults to dev_api_key_change_in_production and should be rotated for production use.
Sources: docker-compose.yml:25-106, README.md:9-10
Common Operations
Starting Services
Viewing Logs
Service Management
Rebuilding Containers
Database Access
Troubleshooting
Sources: docker-compose.yml:1-198, README.md:69-72
Integration with Redis Client
The backend service connects to Redis using the centralized configuration system.
Connection Resolution:
The get_redis_client() function in orchestrator/core/redis/client.py:149-198 attempts connection in this order:
REDIS_URL (for Railway/Heroku deployments) - parsed for host, port, password, db
Individual variables -
REDIS_HOST,REDIS_PORT,REDIS_PASSWORDReturns None if unconfigured (Redis is optional)
Docker Compose Configuration:
The backend service receives Redis connection details via environment variables docker-compose.yml:90-92:
Connection Pooling:
The RedisClient maintains a connection pool with max_connections=50 orchestrator/core/redis/client.py:22-29, which is sized appropriately for the development backend's typical load.
Sources: docker-compose.yml:90-92, orchestrator/core/redis/client.py:149-198, orchestrator/core/redis/client.py:14-35
Last updated

