124 lines
2.4 KiB
YAML
124 lines
2.4 KiB
YAML
services:
|
|
api1:
|
|
container_name: api1
|
|
hostname: api1
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
entrypoint: ./docker/entrypoint.sh
|
|
networks:
|
|
- backend
|
|
- payment-processor
|
|
volumes:
|
|
- .:/app
|
|
depends_on:
|
|
- redis
|
|
- database
|
|
# deploy:
|
|
# resources:
|
|
# limits:
|
|
# cpus: "0.15"
|
|
# memory: "80MB"
|
|
healthcheck:
|
|
test: [ "CMD", "curl", "-f", "http://api1:9999" ]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
api2:
|
|
container_name: api2
|
|
hostname: api2
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
entrypoint: ./docker/entrypoint.sh
|
|
depends_on:
|
|
- redis
|
|
- database
|
|
networks:
|
|
- backend
|
|
- payment-processor
|
|
volumes:
|
|
- .:/app
|
|
# deploy:
|
|
# resources:
|
|
# limits:
|
|
# cpus: "0.15"
|
|
# memory: "80MB"
|
|
healthcheck:
|
|
test: [ "CMD", "curl", "-f", "http://api2:9999" ]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
|
|
nginx:
|
|
image: nginx:latest
|
|
container_name: nginx
|
|
hostname: nginx
|
|
ports:
|
|
- "9999:9999"
|
|
volumes:
|
|
- ./nginx.conf:/etc/nginx/nginx.conf
|
|
networks:
|
|
- backend
|
|
depends_on:
|
|
- api1
|
|
- api2
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "0.10"
|
|
memory: "20MB"
|
|
|
|
redis:
|
|
image: redis:7.2-alpine
|
|
hostname: redis
|
|
platform: linux/amd64
|
|
ports:
|
|
- "6379:6379"
|
|
networks:
|
|
- backend
|
|
volumes:
|
|
- redis_data:/data
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "0.05"
|
|
memory: "20MB"
|
|
database:
|
|
container_name: database
|
|
image: postgres:alpine
|
|
hostname: database
|
|
platform: linux/amd64
|
|
ports:
|
|
- "5432:5432"
|
|
healthcheck:
|
|
test: [ "CMD-SHELL", "pg_isready -U postgres -d payment" ]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
environment:
|
|
- POSTGRES_DB=payment
|
|
- POSTGRES_USER=postgres
|
|
- POSTGRES_PASSWORD=postgres_pwd
|
|
volumes:
|
|
- database_volume:/var/lib/postgresql/data
|
|
- ./docker/db_init/:/docker-entrypoint-initdb.d/
|
|
networks:
|
|
- backend
|
|
deploy:
|
|
resources:
|
|
limits:
|
|
cpus: "0.5"
|
|
memory: "110MB"
|
|
|
|
networks:
|
|
backend:
|
|
driver: bridge
|
|
payment-processor:
|
|
external: true
|
|
|
|
volumes:
|
|
database_volume:
|
|
redis_data:
|