Пофиксила 2 замечания: добавила one-shot миграции и лимиты ресурсов для всех сервисов
This commit is contained in:
+53
-1
@@ -4,7 +4,9 @@ x-required-roles:
|
||||
- postgres
|
||||
- load_balancer
|
||||
|
||||
# Лабораторная 3. LB + 2 API-реплики + PostgreSQL + Redis.
|
||||
# Лабораторная 3. LB + 2 API-реплики + PostgreSQL + Redis + one-shot migrate.
|
||||
# Миграции вынесены в отдельный сервис migrate.
|
||||
# Лимиты CPU/RAM заданы для ВСЕХ сервисов
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:18.6-alpine
|
||||
@@ -22,6 +24,14 @@ services:
|
||||
retries: 20
|
||||
start_period: 30s
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "1.0"
|
||||
memory: 1G
|
||||
reservations:
|
||||
cpus: "0.25"
|
||||
memory: 256M
|
||||
|
||||
redis:
|
||||
image: redis:7.4.1-alpine
|
||||
@@ -36,6 +46,35 @@ services:
|
||||
retries: 10
|
||||
start_period: 3s
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.5"
|
||||
memory: 256M
|
||||
reservations:
|
||||
cpus: "0.1"
|
||||
memory: 64M
|
||||
|
||||
migrate:
|
||||
build: .
|
||||
image: mtuci-messenger:lab3
|
||||
# One-shot: применяет схему БД один раз и завершается с кодом 0.
|
||||
# Реплики api стартуют только после успешного выхода (см. depends_on).
|
||||
command: ["python", "-m", "app.storage.db"]
|
||||
env_file:
|
||||
- .env
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
restart: "no"
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.5"
|
||||
memory: 256M
|
||||
reservations:
|
||||
cpus: "0.1"
|
||||
memory: 64M
|
||||
|
||||
api:
|
||||
build: .
|
||||
@@ -45,6 +84,8 @@ services:
|
||||
env_file:
|
||||
- .env
|
||||
depends_on:
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
@@ -62,6 +103,9 @@ services:
|
||||
limits:
|
||||
cpus: "1.0"
|
||||
memory: 512M
|
||||
reservations:
|
||||
cpus: "0.25"
|
||||
memory: 128M
|
||||
|
||||
lb:
|
||||
image: nginx:1.27.3-alpine
|
||||
@@ -74,6 +118,14 @@ services:
|
||||
api:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.5"
|
||||
memory: 128M
|
||||
reservations:
|
||||
cpus: "0.1"
|
||||
memory: 32M
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
|
||||
Reference in New Issue
Block a user