feat: конф нгинкс, тесты, ключ идмпт etc

This commit is contained in:
Enterxx2
2026-10-20 10:41:56 +03:00
parent aa971fbd27
commit b53e5d1077
63 changed files with 5013 additions and 153 deletions
+93 -16
View File
@@ -1,27 +1,100 @@
name: messenger-lab3
x-api: &api
build: .
x-app: &app
build:
context: .
args:
APP_REVISION: ${APP_REVISION:-dev}
image: mtusi-messenger:lab3
restart: unless-stopped
env_file:
- .env
environment: &api-network
environment: &app-network
DB_HOST: postgres
DB_PORT: "5432"
VALKEY_HOST: valkey
VALKEY_PORT: "6379"
x-api-resources: &api-resources
resources:
limits:
cpus: "1.0"
memory: 512M
reservations:
cpus: "0.25"
memory: 128M
x-api: &api
<<: *app
restart: unless-stopped
depends_on:
migrate:
condition: service_completed_successfully
postgres:
condition: service_healthy
valkey:
condition: service_started
networks:
- edge
- backend
- default
healthcheck:
test: ["CMD", "python", "src/healthcheck.py"]
interval: 5s
timeout: 3s
retries: 2
start_period: 20s
start_interval: 1s
stop_grace_period: 10s
services:
nginx:
image: nginx:1.28.0-alpine3.21
restart: unless-stopped
depends_on:
api:
condition: service_healthy
ports:
- "127.0.0.1:${LB_PORT:-8080}:8080"
- "127.0.0.1:${LB_EXPIRY_PORT:-8081}:8081"
volumes:
- ./infra/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./infra/nginx/errors.conf:/etc/nginx/errors.conf:ro
networks:
- edge
healthcheck:
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8090/healthz"]
interval: 5s
timeout: 2s
retries: 3
stop_grace_period: 10s
deploy:
resources:
limits:
cpus: "0.5"
memory: 64M
api:
<<: *api
deploy:
<<: *api-resources
replicas: ${API_REPLICAS:-2}
migrate:
<<: *app
command: ["python", "src/migrate.py"]
restart: "no"
depends_on:
postgres:
condition: service_healthy
networks:
- backend
healthcheck:
disable: true
deploy:
resources:
limits:
cpus: "0.5"
memory: 256M
postgres:
image: postgres:18.2-alpine3.22
restart: unless-stopped
@@ -37,12 +110,14 @@ services:
timeout: 3s
retries: 15
start_period: 10s
ports:
- "127.0.0.1:${DB_PORT}:5432"
networks:
- backend
- default
stop_grace_period: 30s
deploy:
resources:
limits:
cpus: "1.5"
memory: 512M
valkey:
image: valkey/valkey:8.1.4-alpine3.22
@@ -68,23 +143,25 @@ services:
retries: 15
networks:
- backend
api:
<<: *api
ports:
- "127.0.0.1:${APP_PORT}:${APP_PORT}"
deploy:
resources:
limits:
cpus: "0.25"
memory: 96M
api-short-ttl:
<<: *api
profiles:
- expiry
environment:
<<: *api-network
<<: *app-network
SESSION_TTL_SECONDS: "2"
ports:
- "127.0.0.1:8081:${APP_PORT}"
deploy:
<<: *api-resources
replicas: 1
networks:
edge: {}
backend:
internal: true