This commit is contained in:
Getlles
2026-11-09 14:52:10 +03:00
parent 234e2a2fd7
commit 21218e0392
5 changed files with 96 additions and 3 deletions
+32
View File
@@ -7,6 +7,14 @@ services:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}
volumes:
- pgdata:/var/lib/postgresql/data
deploy:
resources:
limits:
cpus: '0.50'
memory: 512M
reservations:
cpus: '0.10'
memory: 128M
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d messenger"]
interval: 3s
@@ -18,6 +26,11 @@ services:
command: redis-server --save 60 1 --loglevel warning
volumes:
- redisdata:/data
deploy:
resources:
limits:
cpus: '0.25'
memory: 256M
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 3s
@@ -40,11 +53,18 @@ services:
api-1:
build: .
stop_grace_period: 15s
environment:
- DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}@postgres:5432/messenger
- REDIS_URL=redis://redis:6379/0
- SESSION_TTL_SECONDS=3600
- INSTANCE_ID=api-replica-1
- SECRET_HMAC_KEY=${SECRET_HMAC_KEY}
deploy:
resources:
limits:
cpus: '0.50'
memory: 256M
depends_on:
postgres:
condition: service_healthy
@@ -60,11 +80,18 @@ services:
api-2:
build: .
stop_grace_period: 15s
environment:
- DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD:?set POSTGRES_PASSWORD in .env}@postgres:5432/messenger
- REDIS_URL=redis://redis:6379/0
- SESSION_TTL_SECONDS=3600
- INSTANCE_ID=api-replica-2
- SECRET_HMAC_KEY=${SECRET_HMAC_KEY}
deploy:
resources:
limits:
cpus: '0.50'
memory: 256M
depends_on:
postgres:
condition: service_healthy
@@ -84,6 +111,11 @@ services:
- "8080:8080"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
deploy:
resources:
limits:
cpus: '0.25'
memory: 128M
depends_on:
- api-1
- api-2