Files
mtusi2026lab2/compose.yaml

87 lines
2.1 KiB
YAML

name: mtusi-lab2
x-api: &api
image: mtusi-messenger:lab2
build:
context: .
args:
VCS_REF: ${VCS_REF:-uncommitted}
init: false
user: "10001:10001"
read_only: true
tmpfs:
- /tmp:rw,noexec,nosuid,size=16m
cap_drop: [ALL]
security_opt: [no-new-privileges:true]
pids_limit: 96
cpus: 1
mem_limit: 512m
memswap_limit: 512m
secrets: [database_url, cache_url]
environment:
APP_HOST: 0.0.0.0
APP_PORT: 8080
APP_ENV: lab2
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
DATABASE_POOL_SIZE: 8
DATABASE_URL_FILE: /run/secrets/database_url
CACHE_URL_FILE: /run/secrets/cache_url
networks: [backend]
services:
postgres:
image: postgres:18.3
environment:
POSTGRES_USER: messenger
POSTGRES_DB: messenger
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
secrets: [postgres_password]
volumes: [postgres_data:/var/lib/postgresql]
command: [postgres, -c, fsync=on, -c, synchronous_commit=on, -c, full_page_writes=on]
healthcheck:
test: [CMD-SHELL, "pg_isready -U messenger -d messenger"]
interval: 2s
timeout: 2s
retries: 30
cpus: 1
mem_limit: 512m
memswap_limit: 512m
networks: [backend]
valkey:
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: 1s
retries: 20
cpus: 0.5
mem_limit: 128m
memswap_limit: 128m
networks: [backend]
migrate:
<<: *api
command: [python, -m, messenger.migrate]
healthcheck: {disable: true}
depends_on:
postgres: {condition: service_healthy}
api:
<<: *api
ports: ["127.0.0.1:${PUBLIC_PORT:-8082}:8080"]
depends_on:
migrate: {condition: service_completed_successfully}
valkey: {condition: service_healthy}
networks:
backend: {}
volumes:
postgres_data:
secrets:
postgres_password:
file: ./secrets/postgres_password
database_url:
file: ./secrets/database_url
cache_url:
file: ./secrets/cache_url