forked from mtusi2026/mtusi2026lab2
67 lines
1.9 KiB
YAML
67 lines
1.9 KiB
YAML
name: mtusi-vasilev-lab2
|
|
x-application: &application
|
|
image: ${API_IMAGE:-mtusi-vasilev:lab2}
|
|
build:
|
|
context: .
|
|
args:
|
|
VCS_REF: ${VCS_REF:-uncommitted}
|
|
environment:
|
|
DATABASE_URL_FILE: /run/secrets/database_url
|
|
CACHE_URL_FILE: /run/secrets/cache_url
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
secrets: [database_url, cache_url]
|
|
cpus: 1
|
|
mem_limit: 512m
|
|
pids_limit: 96
|
|
read_only: true
|
|
tmpfs: ["/tmp:size=16m,noexec,nosuid"]
|
|
cap_drop: [ALL]
|
|
security_opt: [no-new-privileges:true]
|
|
stop_grace_period: 8s
|
|
services:
|
|
postgres:
|
|
image: postgres:17.10-alpine
|
|
environment:
|
|
POSTGRES_USER: messenger
|
|
POSTGRES_DB: messenger
|
|
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
|
secrets: [postgres_password]
|
|
volumes: [postgres_data:/var/lib/postgresql/data]
|
|
healthcheck:
|
|
test: [CMD-SHELL, "pg_isready -U messenger -d messenger"]
|
|
interval: 2s
|
|
timeout: 2s
|
|
retries: 15
|
|
cpus: 1
|
|
mem_limit: 768m
|
|
command: [postgres, -c, fsync=on, -c, synchronous_commit=on, -c, full_page_writes=on]
|
|
cache:
|
|
image: valkey/valkey:8.1.3-alpine
|
|
command: [valkey-server, --save, "", --appendonly, "no", --maxmemory, 64mb, --maxmemory-policy, allkeys-lru]
|
|
healthcheck:
|
|
test: [CMD, valkey-cli, ping]
|
|
interval: 2s
|
|
timeout: 2s
|
|
retries: 15
|
|
cpus: 0.5
|
|
mem_limit: 128m
|
|
migrate:
|
|
<<: *application
|
|
command: [python, -m, messenger.migrate]
|
|
healthcheck:
|
|
disable: true
|
|
depends_on:
|
|
postgres: {condition: service_healthy}
|
|
api:
|
|
<<: *application
|
|
ports: ["127.0.0.1:${PUBLIC_PORT:-8082}:8080"]
|
|
depends_on:
|
|
migrate: {condition: service_completed_successfully}
|
|
cache: {condition: service_healthy}
|
|
volumes:
|
|
postgres_data:
|
|
secrets:
|
|
postgres_password: {file: ./secrets/postgres_password}
|
|
database_url: {file: ./secrets/database_url}
|
|
cache_url: {file: ./secrets/cache_url}
|