Developer-Focused Guide

API Gateway Proxy for Developers with Docker

Complete developer guide to setting up and deploying API gateway proxy with Docker. From local development to production deployment with Docker Compose and best practices.

terminal
$ docker compose up -d
[+] Running 4/4
✔ Network api-gateway_default Created
✔ Container redis Started
✔ Container api-gateway Started
✔ Container monitoring Started

API Gateway running on http://localhost:8080
Monitoring dashboard: http://localhost:3000
$ curl http://localhost:8080/health
{"status":"healthy","version":"1.0.0","uptime":"2s"}

Complete Setup Guide

Follow these steps to get your API gateway proxy running with Docker in under 10 minutes.

1

Prerequisites & Environment Setup

Ensure you have the required tools installed and configured for Docker development.

check-setup.sh
# Check Docker installation
docker --version
# Docker version 24.0.7, build 24.0.7-1

# Check Docker Compose installation
docker compose version
# Docker Compose version v2.23.3

# Check available resources
docker info | grep -E "(Total Memory|CPUs)"
# Total Memory: 15.62GiB
# CPUs: 8
💡
Pro Tip

If you don't have Docker installed, visit Docker's official documentation for installation instructions for your operating system.

2

Basic Docker Configuration

Create a simple Docker configuration file to get started quickly.

Dockerfile
# Use official Node.js 18 Alpine image
FROM node:18-alpine

# Create app directory
WORKDIR /usr/src/app

# Copy package files
COPY package*.json ./

# Install dependencies
RUN npm ci --only=production

# Copy application source
COPY . .

# Expose API gateway port
EXPOSE 8080

# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
  CMD node healthcheck.js

# Start the application
CMD [ "node", "server.js" ]
3

Docker Compose for Development

Create a Docker Compose configuration for local development with all required services.

📦

docker-compose.yml

Complete development environment configuration

docker-compose.yml
version: '3.8'

services:
  api-gateway:
    build: .
    container_name: api-gateway
    ports:
      - "8080:8080"
    environment:
      - NODE_ENV=development
      - REDIS_URL=redis://redis:6379
      - LOG_LEVEL=debug
    volumes:
      - ./src:/usr/src/app/src
      - ./logs:/usr/src/app/logs
    depends_on:
      - redis
      - postgres
    networks:
      - api-network

  redis:
    image: redis:7-alpine
    container_name: api-redis
    ports:
      - "6379:6379"
    volumes:
      - redis-data:/data
    command: redis-server --appendonly yes
    networks:
      - api-network

  postgres:
    image: postgres:15-alpine
    container_name: api-postgres
    environment:
      - POSTGRES_DB=api_gateway
      - POSTGRES_USER=api_user
      - POSTGRES_PASSWORD=api_password
    ports:
      - "5432:5432"
    volumes:
      - postgres-data:/var/lib/postgresql/data
      - ./init.sql:/docker-entrypoint-initdb.d/init.sql
    networks:
      - api-network

  monitoring:
    image: grafana/grafana:latest
    container_name: api-monitoring
    ports:
      - "3000:3000"
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=admin
    volumes:
      - grafana-data:/var/lib/grafana
    networks:
      - api-network

volumes:
  redis-data:
  postgres-data:
  grafana-data:

networks:
  api-network:
    driver: bridge
🚀
Quick Start

Save this configuration as docker-compose.yml and run docker compose up -d to start all services. Access the API gateway at http://localhost:8080 and monitoring dashboard at http://localhost:3000.

4

Production Deployment

Configure your API gateway proxy for production deployment with security, monitoring, and scaling.

docker-compose.prod.yml
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
Security Notice

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.

Production Readiness Checklist

Essential checks before deploying to production

Security Configuration

✅ Use Docker secrets for sensitive data
✅ Implement proper network segmentation
✅ Configure container resource limits
✅ Enable Docker content trust
✅ Regular security scanning

Monitoring & Logging

✅ Centralized logging (ELK stack, Loki)
✅ Metrics collection (Prometheus, Grafana)
✅ Health check endpoints
✅ Alerting configuration
✅ Performance monitoring

Deployment & Scaling

✅ CI/CD pipeline integration
✅ Blue-green deployment strategy
✅ Horizontal scaling configuration
✅ Zero-downtime deployments
✅ Rollback procedures

Backup & Recovery

✅ Regular data backups
✅ Disaster recovery plan
✅ Point-in-time recovery testing
✅ Configuration versioning
✅ Backup verification

Partner Resources

Explore more Docker and API gateway resources from our developer community

🐳

Docker API Gateway Proxy

Comprehensive Docker deployment guide for API gateway proxy with production configurations.

View Guide →
⚙️

Kubernetes Setup Guide

Production Kubernetes deployment for AI API proxies with scaling and monitoring.

Read Guide →
🔧

Self-Hosted Solutions

Complete guide to self-hosted AI API gateway solutions with detailed configuration.

Learn More →
🏆

Best AI API Proxy 2026

Expert analysis and comparison of the best AI API proxy solutions for developers.

See Rankings →