From d6de8c2259e26ecf51bd9337e8d2a17ba4e8469a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2=20Maximillian?= =?UTF-8?q?=20=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Wed, 7 Oct 2026 10:45:23 +0300 Subject: [PATCH] feat(compose): run api replicas behind load balancer --- compose.yaml | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/compose.yaml b/compose.yaml index d6cf8c6..3e4e4f5 100644 --- a/compose.yaml +++ b/compose.yaml @@ -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