forked from mtusi2026/mtusi2026lab4
feat: перенос структуры приложения из третьей лабы
This commit is contained in:
+154
@@ -0,0 +1,154 @@
|
||||
services:
|
||||
load_balancer:
|
||||
image: nginx:1.27-alpine
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- ./infra/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
depends_on:
|
||||
api-1:
|
||||
condition: service_healthy
|
||||
api-2:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/health/live"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 5
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.25'
|
||||
memory: 128M
|
||||
|
||||
migration:
|
||||
image: postgres:16-alpine
|
||||
restart: "no"
|
||||
environment:
|
||||
PGPASSWORD: postgres
|
||||
command: >
|
||||
sh -c "until pg_isready -h postgres -U postgres -d messenger; do sleep 1; done;
|
||||
psql -h postgres -U postgres -d messenger -f /docker-entrypoint-initdb.d/init.sql"
|
||||
volumes:
|
||||
- ./infra/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.25'
|
||||
memory: 128M
|
||||
|
||||
api-1:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: highload-messenger:lab3
|
||||
stop_grace_period: 15s
|
||||
environment:
|
||||
APP_HOST: "0.0.0.0"
|
||||
APP_PORT: "8080"
|
||||
APP_ENV: "lab"
|
||||
INSTANCE_ID: "api-1"
|
||||
SESSION_TTL_SECONDS: "3600"
|
||||
DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/messenger"
|
||||
SESSION_STORE: "redis"
|
||||
CACHE_URL: "redis://redis:6379/0"
|
||||
IDEMPOTENCY_TTL_SECONDS: "86400"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
migration:
|
||||
condition: service_completed_successfully
|
||||
healthcheck:
|
||||
test: ["CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8080/health/ready')"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 5
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.50'
|
||||
memory: 512M
|
||||
|
||||
api-2:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: highload-messenger:lab3
|
||||
stop_grace_period: 15s
|
||||
environment:
|
||||
APP_HOST: "0.0.0.0"
|
||||
APP_PORT: "8080"
|
||||
APP_ENV: "lab"
|
||||
INSTANCE_ID: "api-2"
|
||||
SESSION_TTL_SECONDS: "3600"
|
||||
DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/messenger"
|
||||
SESSION_STORE: "redis"
|
||||
CACHE_URL: "redis://redis:6379/0"
|
||||
IDEMPOTENCY_TTL_SECONDS: "86400"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
migration:
|
||||
condition: service_completed_successfully
|
||||
healthcheck:
|
||||
test: ["CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8080/health/ready')"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 5
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.50'
|
||||
memory: 512M
|
||||
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: messenger
|
||||
volumes:
|
||||
- pg_data:/var/lib/postgresql/data
|
||||
- ./infra/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres -d messenger"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 5
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.50'
|
||||
memory: 512M
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
command: ["redis-server", "--appendonly", "yes"]
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 5
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.25'
|
||||
memory: 256M
|
||||
|
||||
volumes:
|
||||
pg_data:
|
||||
redis_data:
|
||||
Reference in New Issue
Block a user