Skip to main content

Gateway Service Deployment

Docker Deployment

Build Image

cd shared/gateway
docker build -t gateway:latest .

Run Container

docker run -d \
--name gateway \
-p 8000:8000 \
-e AUTHENTICATION_SERVICE_URL=http://authentication:8001 \
-e REDIS_URL=redis://redis:6379 \
gateway:latest

Docker Compose

The service is included in infra/compose.yml:

gateway:
build: ./shared/gateway
ports:
- "8000:8000"
environment:
- AUTHENTICATION_SERVICE_URL=http://authentication:8001
- REDIS_URL=redis://redis:6379
depends_on:
- authentication
- redis

Production Deployment

Build Release Binary

cd shared/gateway
cargo build --release

Run Binary

./target/release/gateway

Systemd Service

Create /etc/systemd/system/gateway.service:

[Unit]
Description=Gateway Service
After=network.target redis.service

[Service]
Type=simple
User=gateway
WorkingDirectory=/opt/gateway
ExecStart=/opt/gateway/gateway
Restart=always
RestartSec=5
Environment="HOST=0.0.0.0"
Environment="PORT=8000"

[Install]
WantedBy=multi-user.target

Health Checks

  • GET /health - Basic health check
  • GET /health/detailed - Detailed health including backend services

Monitoring

Metrics

Prometheus metrics available at /metrics.

Logging

Structured logging to stdout/stderr. Configure log aggregation in production.

Scaling

The gateway can be horizontally scaled:

  1. Run multiple instances behind a load balancer
  2. Ensure all instances connect to the same Redis
  3. Use sticky sessions if needed (for WebSocket)

SSL/TLS

Configure reverse proxy (nginx/traefik) for SSL termination in front of the gateway.