92 lines
2.3 KiB
YAML
92 lines
2.3 KiB
YAML
version: '3.8'
|
|
|
|
services:
|
|
# PostgreSQL database
|
|
postgres:
|
|
image: postgres:15-alpine
|
|
container_name: leaderboard-postgres
|
|
environment:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: leaderboard_db
|
|
ports:
|
|
- "5432:5432"
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# Redis cache
|
|
redis:
|
|
image: redis:7-alpine
|
|
container_name: leaderboard-redis
|
|
ports:
|
|
- "6379:6379"
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
# Kafka message broker
|
|
zookeeper:
|
|
image: confluentinc/cp-zookeeper:7.5.0
|
|
container_name: leaderboard-zookeeper
|
|
environment:
|
|
ZOOKEEPER_CLIENT_PORT: 2181
|
|
ZOOKEEPER_TICK_TIME: 2000
|
|
|
|
kafka:
|
|
image: confluentinc/cp-kafka:7.5.0
|
|
container_name: leaderboard-kafka
|
|
depends_on:
|
|
- zookeeper
|
|
ports:
|
|
- "9092:9092"
|
|
environment:
|
|
KAFKA_BROKER_ID: 1
|
|
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
|
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
|
|
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
|
|
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
|
|
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
|
|
healthcheck:
|
|
test: ["CMD", "kafka-broker-api-versions", "--bootstrap-server", "localhost:9092"]
|
|
interval: 10s
|
|
timeout: 10s
|
|
retries: 5
|
|
|
|
# Application service
|
|
app:
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
target: production
|
|
container_name: leaderboard-app
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
kafka:
|
|
condition: service_healthy
|
|
ports:
|
|
- "3000:3000"
|
|
environment:
|
|
NODE_ENV: production
|
|
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/leaderboard_db
|
|
REDIS_HOST: redis
|
|
REDIS_PORT: 6379
|
|
KAFKA_BROKERS: kafka:29092
|
|
JWT_SECRET: your-jwt-secret-for-docker
|
|
JWT_EXPIRES_IN: 7d
|
|
PORT: 3000
|
|
command: >
|
|
sh -c "npx prisma migrate deploy && node dist/main"
|
|
|
|
volumes:
|
|
postgres_data:
|