feat: полная реализация

This commit is contained in:
2026-11-10 15:27:10 +03:00
parent 7734b222f8
commit 5cf99b5384
18 changed files with 935 additions and 211 deletions
+67 -17
View File
@@ -1,22 +1,26 @@
version: '3.8'
services:
postgres:
image: postgres:16-alpine
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 3
start_period: 40s
environment:
POSTGRES_DB: lab3
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_USER: app
POSTGRES_PASSWORD: app
POSTGRES_DB: app
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U app -d app"]
interval: 5s
timeout: 3s
retries: 5
networks:
- lab3net
deploy:
resources:
limits:
cpus: "1.0"
memory: 512M
api1:
build:
@@ -24,14 +28,27 @@ services:
dockerfile: Dockerfile
environment:
APP_INSTANCE_ID: api1
APP_PORT: 8080
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/lab3
APP_PORT: "8080"
DATABASE_URL: postgres://app:app@postgres:5432/app?sslmode=disable
expose:
- "8080"
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8080/health"]
interval: 5s
timeout: 3s
retries: 5
start_period: 10s
stop_grace_period: 15s
networks:
- lab3net
stop_grace_period: 15s
deploy:
resources:
limits:
cpus: "1.0"
memory: 256M
api2:
build:
@@ -39,17 +56,50 @@ services:
dockerfile: Dockerfile
environment:
APP_INSTANCE_ID: api2
APP_PORT: 8080
DATABASE_URL: postgresql://postgres:postgres@postgres:5432/lab3
APP_PORT: "8080"
DATABASE_URL: postgres://app:app@postgres:5432/app?sslmode=disable
expose:
- "8080"
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8080/health"]
interval: 5s
timeout: 3s
retries: 5
start_period: 10s
stop_grace_period: 15s
networks:
- lab3net
stop_grace_period: 15s
deploy:
resources:
limits:
cpus: "1.0"
memory: 256M
haproxy:
image: haproxy:2.9-alpine
ports:
- "8080:8080"
volumes:
- ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
depends_on:
api1:
condition: service_healthy
api2:
condition: service_healthy
networks:
- lab3net
deploy:
resources:
limits:
cpus: "0.5"
memory: 128M
networks:
lab3net:
driver: bridge
volumes:
pgdata: