feat(compose): run api replicas behind load balancer
This commit is contained in:
+40
-5
@@ -43,14 +43,29 @@ services:
|
||||
networks:
|
||||
- internal
|
||||
|
||||
migrate:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: mtusi-messenger-api:lab3
|
||||
restart: "no"
|
||||
command: ["migrate"]
|
||||
environment:
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
secrets:
|
||||
- database_url
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- internal
|
||||
|
||||
api:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: mtusi-messenger-api:lab2
|
||||
image: mtusi-messenger-api:lab3
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8080:8080"
|
||||
environment:
|
||||
APP_HOST: "0.0.0.0"
|
||||
APP_PORT: "8080"
|
||||
@@ -67,12 +82,32 @@ services:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
expose:
|
||||
- "8080"
|
||||
stop_grace_period: 15s
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1"]
|
||||
interval: 10s
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
start_period: 15s
|
||||
start_period: 10s
|
||||
deploy:
|
||||
replicas: 2
|
||||
networks:
|
||||
- internal
|
||||
|
||||
lb:
|
||||
image: nginx:1.27.4-alpine
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ./infra/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_started
|
||||
networks:
|
||||
- internal
|
||||
|
||||
|
||||
Reference in New Issue
Block a user