Yimaru-BackEnd/docker-compose.yml

140 lines
3.0 KiB
YAML

version: "3.8"
services:
postgres:
image: postgres:16-alpine
ports:
- 5422:5432
environment:
- POSTGRES_PASSWORD=secret
- POSTGRES_USER=root
- POSTGRES_DB=gh
networks:
- app
healthcheck:
test: ["CMD-SHELL", "pg_isready -U root -d gh"]
interval: 5s
timeout: 3s
retries: 5
volumes:
- postgres_data:/var/lib/postgresql/data
- ./exports:/exports
mongo:
container_name: fortunebet-mongo
image: mongo:7.0.11
restart: always
ports:
- "27017:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: secret
volumes:
- mongo_data:/data/db
networks:
- app
healthcheck:
test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
interval: 10s
timeout: 5s
retries: 5
migrate:
image: migrate/migrate
volumes:
- ./db/migrations:/migrations
depends_on:
postgres:
condition: service_healthy
command:
[
"-path",
"/migrations",
"-database",
"postgresql://root:secret@postgres:5432/gh?sslmode=disable",
"up",
]
networks:
- app
redis:
image: redis:7-alpine
ports:
- "6379:6379"
networks:
- app
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
zookeeper:
image: confluentinc/cp-zookeeper:7.5.0
container_name: zookeeper
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
networks:
- app
kafka:
image: confluentinc/cp-kafka:7.5.0
depends_on:
- zookeeper
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,PLAINTEXT_HOST://0.0.0.0:29092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,PLAINTEXT_HOST://localhost:29092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
ports:
- "9092:9092"
- "29092:29092"
networks:
- app
app:
build:
context: .
dockerfile: Dockerfile
target: runner
ports:
- ${PORT}:8080
environment:
- DB_URL=postgresql://root:secret@postgres:5432/gh?sslmode=disable
- MONGO_URI=mongodb://root:secret@mongo:27017
- REDIS_ADDR=redis:6379
- KAFKA_BROKERS=kafka:9092
depends_on:
migrate:
condition: service_completed_successfully
mongo:
condition: service_healthy
redis:
condition: service_healthy
networks:
- app
command: ["/app/bin/web"]
# volumes:
# - "C:/Users/User/Desktop:/host-desktop"
test:
build:
context: .
dockerfile: Dockerfile
target: builder
volumes:
- .:/app
command: ["tail", "-f", "/dev/null"]
networks:
- app
networks:
app:
driver: bridge
volumes:
postgres_data:
mongo_data: