Configure your API gateway proxy for production deployment with security, monitoring, and scaling.
version: '3.8'
services:
api-gateway:
image: your-registry/api-gateway:${TAG:-latest}
deploy:
mode: replicated
replicas: 3
update_config:
parallelism: 1
delay: 10s
order: start-first
resources:
limits:
cpus: '0.5'
memory: 512M
reservations:
cpus: '0.25'
memory: 256M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 120s
environment:
- NODE_ENV=production
- REDIS_URL=${REDIS_URL}
- DATABASE_URL=${DATABASE_URL}
- LOG_LEVEL=info
- API_RATE_LIMIT=${API_RATE_LIMIT:-1000}
secrets:
- api_secrets
configs:
- source: gateway_config
target: /app/config/production.json
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
networks:
- api-network
configs:
gateway_config:
file: ./config/production.json
secrets:
api_secrets:
file: ./secrets/api.env
networks:
api-network:
external: true
Always use Docker secrets for sensitive information (API keys, database credentials) in production. Never commit secrets to version control or use environment variables for sensitive data.