| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- # docker-compose.yml
- # client2server with Caddy load balancer
- services:
- # ========================================
- # Redpanda (Kafka-compatible event store)
- # ========================================
- redpanda:
- image: docker.redpanda.com/vectorized/redpanda:v23.11.10
- container_name: client2server-redpanda
- hostname: redpanda
- command: redpanda start --overprovisioned --smp 1 --memory 1G --node-id 0 --pandaproxy-port=8082 --schema-registry-port=8081
- ports:
- - "8082:8082" # REST API
- - "8081:8081" # Schema registry
- - "9092:9092" # Kafka
- environment:
- - REDPANDA_AUTO_CREATE_TOPICS=true
- volumes:
- - redpanda_data:/var/lib/redpanda/data
- networks:
- - client2server
- healthcheck:
- test: ["CMD", "curl", "-f", "http://localhost:8082/health"]
- interval: 10s
- timeout: 5s
- retries: 5
- # ========================================
- # Go Server Instance 1
- # ========================================
- server1:
- build:
- context: ./server
- dockerfile: Dockerfile
- container_name: client2server-server1
- environment:
- - REDPANDA_BROKERS=redpanda:9092
- - TOKEN=${TOKEN:-secret-token}
- - PORT=3843
- depends_on:
- redpanda:
- condition: service_healthy
- networks:
- - client2server
- restart: unless-stopped
- # ========================================
- # Go Server Instance 2
- # ========================================
- server2:
- build:
- context: ./server
- dockerfile: Dockerfile
- container_name: client2server-server2
- environment:
- - REDPANDA_BROKERS=redpanda:9092
- - TOKEN=${TOKEN:-secret-token}
- - PORT=3843
- depends_on:
- redpanda:
- condition: service_healthy
- networks:
- - client2server
- restart: unless-stopped
- # ========================================
- # Go Server Instance 3 (optional)
- # ========================================
- # server3:
- # build:
- # context: ./server
- # dockerfile: Dockerfile
- # container_name: client2server-server3
- # environment:
- # - REDPANDA_BROKERS=redpanda:9092
- # - TOKEN=${TOKEN:-secret-token}
- # - PORT=3843
- # depends_on:
- # redpanda:
- # condition: service_healthy
- # networks:
- # - client2server
- # restart: unless-stopped
- # ========================================
- # Caddy Load Balancer
- # ========================================
- caddy:
- image: caddy:2-alpine
- container_name: client2server-caddy
- ports:
- - "80:80"
- - "443:443"
- - "3843:3843" # Unified WebSocket + HTTP API
- volumes:
- - ./Caddyfile:/etc/caddy/Caddyfile:ro
- - caddy_data:/data
- - caddy_config:/config
- environment:
- - CADDY_INGRESS_NETWORK=caddy
- depends_on:
- - server1
- - server2
- networks:
- - client2server
- restart: unless-stopped
- networks:
- client2server:
- driver: bridge
- volumes:
- redpanda_data:
- caddy_data:
- caddy_config:
|