Разработала необходимый код
This commit is contained in:
+28
-12
@@ -1,9 +1,10 @@
|
||||
x-lab-number: 2
|
||||
x-lab-number: 3
|
||||
x-required-roles:
|
||||
- api
|
||||
- postgres
|
||||
- load_balancer
|
||||
|
||||
# Лабораторная 2. API + PostgreSQL + Redis
|
||||
# Лабораторная 3. LB + 2 API-реплики + PostgreSQL + Redis.
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:18.6-alpine
|
||||
@@ -26,8 +27,6 @@ services:
|
||||
image: redis:7.4.1-alpine
|
||||
container_name: mtuci-redis
|
||||
command: ["redis-server", "--appendonly", "yes", "--appendfsync", "everysec", "--save", "60", "1"]
|
||||
ports:
|
||||
- "127.0.0.1:6379:6379"
|
||||
volumes:
|
||||
- redis-data:/data
|
||||
healthcheck:
|
||||
@@ -40,10 +39,9 @@ services:
|
||||
|
||||
api:
|
||||
build: .
|
||||
image: mtuci-messenger:lab2
|
||||
container_name: mtuci-messenger-lab2
|
||||
ports:
|
||||
- "127.0.0.1:8080:8080"
|
||||
image: mtuci-messenger:lab3
|
||||
# НЕТ container_name: нужно масштабирование (--scale api=2).
|
||||
# НЕТ ports: реплики не публикуют порт наружу — только через LB.
|
||||
env_file:
|
||||
- .env
|
||||
depends_on:
|
||||
@@ -53,18 +51,36 @@ services:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready').read()"]
|
||||
interval: 10s
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
start_period: 10s
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
replicas: 2
|
||||
resources:
|
||||
limits:
|
||||
cpus: "1.0"
|
||||
memory: 512M
|
||||
|
||||
lb:
|
||||
image: nginx:1.27.3-alpine
|
||||
container_name: mtuci-lb
|
||||
ports:
|
||||
- "127.0.0.1:8080:80"
|
||||
volumes:
|
||||
- ./infra/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
name: mtuci2026lab2_postgres-data
|
||||
name: mtuci2026lab3_postgres-data
|
||||
redis-data:
|
||||
name: mtuci2026lab2_redis-data
|
||||
name: mtuci2026lab3_redis-data
|
||||
|
||||
networks:
|
||||
default:
|
||||
name: mtuci2026lab2_default
|
||||
name: mtuci2026lab3_default
|
||||
Reference in New Issue
Block a user