Skip to content

Docker Deployment

Gatewyse provides a Docker Compose configuration that runs all services: the gateway server, background worker, admin dashboard, MongoDB, and Redis.

Quick Start

Terminal window
# Copy and configure environment
cp .env.example .env
# Edit .env with production values (see Configuration guide)
# Start all services
docker compose -f docker/docker-compose.yml up -d

Services

The docker/docker-compose.yml defines five services:

ServiceImage / DockerfilePortDescription
mongodb-primarymongo:727017MongoDB with automatic replica set initialization
redisredis:7-alpine6379Redis with AOF persistence, 256MB memory limit
serverdocker/Dockerfile.server3000Express API gateway
workerdocker/Dockerfile.workerBullMQ background job processor
admindocker/Dockerfile.admin3001Nuxt 4 admin dashboard

All services are connected via a dedicated aigw-net bridge network.

Health Checks

Both infrastructure services include health checks:

  • MongoDB — runs rs.status() every 10 seconds, auto-initializes the replica set if needed (30-second start period)
  • Redis — runs redis-cli ping every 10 seconds

The server and worker services use depends_on with condition: service_healthy to wait for infrastructure readiness.

Volumes

Two named volumes persist data across container restarts:

VolumeMount PointPurpose
mongo-primary-data/data/dbMongoDB data files
redis-data/dataRedis AOF persistence

Production Configuration

Environment Variables

For production, set these in your .env file or pass them directly:

Terminal window
NODE_ENV=production
JWT_SECRET=<random-64-char-string>
JWT_REFRESH_SECRET=<random-64-char-string>
ENCRYPTION_KEY=<random-64-hex-chars>
REDIS_PASSWORD=<strong-password>
SUPER_ADMIN_PASSWORD=<complex-password>

See the Environment Variables reference for all options.

Resource Limits

Add resource constraints to your docker-compose.override.yml:

services:
server:
deploy:
resources:
limits:
cpus: '2.0'
memory: 1G
reservations:
cpus: '0.5'
memory: 512M
worker:
deploy:
resources:
limits:
cpus: '1.0'
memory: 512M
mongodb-primary:
deploy:
resources:
limits:
memory: 2G
redis:
deploy:
resources:
limits:
memory: 256M

Redis Configuration

The default Redis configuration uses:

redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy noeviction

For production, set a Redis password by adding to the Redis service:

redis:
command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy noeviction --requirepass ${REDIS_PASSWORD}

MongoDB Security

For production, add authentication to MongoDB:

mongodb-primary:
command: mongod --replSet rs0 --bind_ip_all --auth --keyFile /data/keyfile

Scaling Workers

The background worker handles 11 BullMQ queues (audio processing, audit log backup, cache management, embedding generation, health checks, usage aggregation, and more). To scale workers horizontally:

Terminal window
docker compose -f docker/docker-compose.yml up -d --scale worker=3

Each worker instance processes jobs from all queues. BullMQ handles job distribution and locking via Redis.

Useful Commands

Terminal window
# View logs
docker compose -f docker/docker-compose.yml logs -f server
# Restart a single service
docker compose -f docker/docker-compose.yml restart server
# Stop all services
docker compose -f docker/docker-compose.yml down
# Stop and remove volumes (deletes all data)
docker compose -f docker/docker-compose.yml down -v
# Rebuild after code changes
docker compose -f docker/docker-compose.yml up -d --build