forked from mtusi2026/mtusi2026lab3
ЛР 3 — БВТ-2302 — Сабитов — на 3
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
name: mtusi-lab3
|
||||
x-db-env: &db-env
|
||||
POSTGRES_HOST: db
|
||||
POSTGRES_USER: ${POSTGRES_USER:?set POSTGRES_USER in .env}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}
|
||||
POSTGRES_DB: ${POSTGRES_DB:?set POSTGRES_DB in .env}
|
||||
x-api: &api
|
||||
build: .
|
||||
restart: unless-stopped
|
||||
stop_grace_period: 4s
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=2).close()"]
|
||||
interval: 2s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
start_period: 3s
|
||||
services:
|
||||
db:
|
||||
image: postgres:16.16-bookworm
|
||||
restart: unless-stopped
|
||||
environment: *db-env
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -U \"$$POSTGRES_USER\" -d \"$$POSTGRES_DB\""]
|
||||
interval: 2s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
migrate:
|
||||
build: .
|
||||
environment: *db-env
|
||||
command: ["python", "-m", "app.migrate"]
|
||||
restart: "no"
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
api1:
|
||||
<<: *api
|
||||
environment:
|
||||
<<: *db-env
|
||||
INSTANCE_ID: api1
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
||||
api2:
|
||||
<<: *api
|
||||
environment:
|
||||
<<: *db-env
|
||||
INSTANCE_ID: api2
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
||||
lb:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: infra/Dockerfile.lb
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
api1:
|
||||
condition: service_healthy
|
||||
api2:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "127.0.0.1:${LAB3_HOST_PORT:-8080}:8080"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1:8080/health/ready"]
|
||||
interval: 2s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
start_period: 3s
|
||||
volumes:
|
||||
pgdata:
|
||||
Reference in New Issue
Block a user