docker-compose.yml for local development and single-node deployments. It builds the Voxray image from source, mounts your config.json, and optionally starts a Redis instance for shared session state.
Docker Compose is the right tool for local development and single-host staging environments. For production at scale — multiple hosts, rolling deploys, autoscaling — use Kubernetes instead. See the scaling guide for a Helm-based setup.
docker-compose.yml
docker-compose.yml
Field annotations
| Field | Value | What it does |
|---|---|---|
build: . | Current directory | Builds the Docker image from the Dockerfile in the repo root each time docker compose up --build is run. Omit --build to reuse a previously built image. |
ports: "8080:8080" | host:container | Maps host port 8080 to the container’s listening port. Change the left side to run multiple instances on different host ports. |
VOXRAY_CONFIG | /app/config.json | Tells Voxray where to read its config at startup. Must match the volume mount destination. |
volumes: ./config.json:/app/config.json:ro | Host path → container path | Mounts your local config.json read-only into the container. The :ro flag prevents the process from accidentally writing to the file. |
depends_on: redis | (commented out) | Uncomment together with the redis service to ensure Redis starts before Voxray. |
redis: image: redis:7-alpine | (commented out) | Lightweight Redis 7 on Alpine. Used only when session_store: redis is set in config. |
redis_data named volume | (commented out) | Persists Redis data across docker compose down restarts. Without this, session data is lost when the Redis container stops. |
Prerequisites
Before running Compose, create your config file from the example:config.json and fill in at minimum:
- Your LLM provider API key (e.g.
openai_api_keyorgroq_api_key) - Your STT provider API key (if not using the same provider)
- Your TTS provider API key
Basic usage
Start (single instance, in-memory sessions)
--build.
View logs
Stop
docker compose down without -v preserves the redis_data named volume, so Redis session state survives a compose restart. Use -v only when you want a completely clean slate.Environment variable injection
There are two ways to pass provider API keys and runtime settings to Voxray in Compose.Option A: Inline in docker-compose.yml
Add keys directly to theenvironment block. This is convenient for local development but keep the file out of version control.
docker-compose.yml (with inline keys)
Option B: .env file (recommended)
Create a.env file in the same directory as docker-compose.yml. Compose automatically loads it.
.env
docker-compose.yml using ${VAR} syntax:
docker-compose.yml (with .env interpolation)
.env to .gitignore so secrets are never committed.
Enabling Redis for session persistence
The default configuration keeps session state in memory. This is fine for a single container, but state is lost if the container restarts and cannot be shared across replicas. Uncomment the Redis service and volume indocker-compose.yml:
docker-compose.yml (with Redis enabled)
Why the named volume matters
Withoutredis_data:/data, Redis stores all data in the container’s writable layer. When the Redis container is removed (e.g. docker compose down), all session state is discarded. With the named volume, redis_data persists on the host even after the container is gone. The next docker compose up reattaches the same volume and Redis resumes from its previous state.
Readiness probe with Redis
Whensession_store=redis is configured, the /ready endpoint returns 503 Service Unavailable if Redis is unreachable. Use this to gate traffic:
Multi-replica setup
To run two Voxray replicas behind a single Compose network (for load testing or verifying Redis session sharing), use thedeploy.replicas key. This requires Redis — sessions must be stored externally so either replica can serve them.
docker-compose.yml (two replicas)
config.json to set the session store:
config.json (session store)
For true production horizontal scaling across multiple hosts, Docker Compose is not the right tool. Use Kubernetes with a Deployment, a Service, and a Redis instance (or Elasticache/Memorystore). See the scaling guide for a complete Kubernetes manifest.
Common commands reference
Next steps
- Docker — single-container build details and Dockerfile reference
- Deployment overview — full environment variable reference, TLS, security checklist
- Scaling — Kubernetes deployment for multi-host production