Реализация лабораторной работы 4 на 4
This commit is contained in:
+188
@@ -0,0 +1,188 @@
|
||||
name: messenger-lab3
|
||||
|
||||
x-app: &app
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
APP_REVISION: ${APP_REVISION:-dev}
|
||||
image: mtusi-messenger:lab3
|
||||
env_file:
|
||||
- .env
|
||||
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
|
||||
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
|
||||
environment:
|
||||
POSTGRES_USER: ${DB_USER}
|
||||
POSTGRES_PASSWORD: ${DB_PASS}
|
||||
POSTGRES_DB: ${DB_NAME}
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U \"$$POSTGRES_USER\" -d \"$$POSTGRES_DB\""]
|
||||
interval: 2s
|
||||
timeout: 3s
|
||||
retries: 15
|
||||
start_period: 10s
|
||||
networks:
|
||||
- backend
|
||||
stop_grace_period: 30s
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "1.5"
|
||||
memory: 512M
|
||||
|
||||
valkey:
|
||||
image: valkey/valkey:8.1.4-alpine3.22
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
VALKEY_PASS: ${VALKEY_PASS}
|
||||
command:
|
||||
- valkey-server
|
||||
- --requirepass
|
||||
- ${VALKEY_PASS}
|
||||
- --save
|
||||
- ""
|
||||
- --appendonly
|
||||
- "no"
|
||||
- --maxmemory
|
||||
- 64mb
|
||||
- --maxmemory-policy
|
||||
- allkeys-lru
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "valkey-cli --no-auth-warning -a \"$$VALKEY_PASS\" ping | grep -q PONG"]
|
||||
interval: 2s
|
||||
timeout: 3s
|
||||
retries: 15
|
||||
networks:
|
||||
- backend
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.25"
|
||||
memory: 96M
|
||||
|
||||
api-short-ttl:
|
||||
<<: *api
|
||||
profiles:
|
||||
- expiry
|
||||
environment:
|
||||
<<: *app-network
|
||||
SESSION_TTL_SECONDS: "2"
|
||||
deploy:
|
||||
<<: *api-resources
|
||||
replicas: 1
|
||||
|
||||
s3:
|
||||
image: chrislusf/seaweedfs:latest
|
||||
restart: unless-stopped
|
||||
command: server -s3 -dir=/data -s3.port=9000
|
||||
environment:
|
||||
AWS_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID}
|
||||
AWS_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY}
|
||||
S3_BUCKET: ${S3_BUCKET}
|
||||
volumes:
|
||||
- s3_data:/data
|
||||
networks:
|
||||
- backend
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://localhost:9000/"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
|
||||
networks:
|
||||
edge: {}
|
||||
backend:
|
||||
internal: true
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
s3_data:
|
||||
Reference in New Issue
Block a user