Files
mtusi2026lab5/compose.yaml

123 lines
3.4 KiB
YAML

name: mtuci-vp5-medvedev
x-api: &api
image: mtuci-vp5:local
build: .
cpus: 1
mem_limit: 2g
stop_grace_period: 10s
read_only: true
security_opt: [no-new-privileges:true]
cap_drop: [ALL]
tmpfs: ['/tmp:uid=65532,gid=65532,size=256m,mode=1777']
environment:
APP_PORT: 8080
SESSION_TTL_SECONDS: 3600
PG_MAX_CONNS: 8
GOMEMLIMIT: 1536MiB
secrets: [database_url, cache_url, s3_credentials]
depends_on:
migrate: {condition: service_completed_successfully}
valkey: {condition: service_started}
bootstrap: {condition: service_completed_successfully}
networks: [private]
services:
postgres:
image: postgres:18.6@sha256:74935e72241653ca55e0414067e6d8763aceb8a810eb51b452253ec3dcfc4336
cpus: 1
mem_limit: 768m
environment:
POSTGRES_USER: messenger
POSTGRES_DB: messenger
POSTGRES_PASSWORD_FILE: /run/secrets/pg_password
secrets: [pg_password]
volumes: [postgres:/var/lib/postgresql]
healthcheck:
test: [CMD-SHELL, pg_isready -U messenger -d messenger]
interval: 2s
timeout: 2s
retries: 30
networks: [private]
valkey:
image: valkey/valkey:9@sha256:418652cfb58ef879d4978c33553735d7147016032d5aefaa14c828e611eb9dfd
cpus: 0.25
mem_limit: 128m
command: [valkey-server, /run/secrets/valkey_conf]
secrets: [valkey_conf]
volumes: [valkey:/data]
networks: [private]
s3:
image: rustfs/rustfs:1.0.0-rc.1@sha256:f53d700fc16809070326f6ab3fb565d48e722364a7bd5a12e47d0a5abe079ce6
cpus: 1
mem_limit: 768m
environment:
RUSTFS_ACCESS_KEY_FILE: /run/secrets/s3_access
RUSTFS_SECRET_KEY_FILE: /run/secrets/s3_secret
RUSTFS_VOLUMES: /data
RUSTFS_CONSOLE_ENABLE: 'false'
secrets: [s3_access,s3_secret]
volumes: [s3:/data]
healthcheck:
test: [CMD,curl,-f,http://127.0.0.1:9000/health]
interval: 2s
timeout: 2s
retries: 40
networks: [private]
migrate:
image: mtuci-vp5:local
build: .
command: [-migrate]
cpus: 0.5
mem_limit: 256m
secrets: [database_url]
depends_on:
postgres: {condition: service_healthy}
networks: [private]
bootstrap:
image: mtuci-vp5:local
build: .
command: [-bootstrap-s3]
cpus: 0.5
mem_limit: 256m
secrets: [database_url,s3_root,s3_credentials]
depends_on:
s3: {condition: service_healthy}
networks: [private]
api:
<<: *api
deploy: {replicas: 2}
worker:
<<: *api
entrypoint: [/worker]
cpus: 1
mem_limit: 2g
tmpfs: ['/tmp:uid=65532,gid=65532,size=256m,mode=1777']
environment:
GOMEMLIMIT: 384MiB
WORKER_MAX_ATTEMPTS: 5
lb:
image: haproxy:3.2-alpine@sha256:1c3568e520453cc8ba98c39501febcf450429c80e6cc27ecad779961d76e597c
cpus: 0.25
mem_limit: 128m
ports: ['127.0.0.1:28205:8080']
volumes: ['./config/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro']
depends_on:
api: {condition: service_started}
networks: [private,edge]
networks:
private: {internal: true}
edge: {}
volumes:
postgres: {}
valkey: {}
s3: {}
secrets:
pg_password: {file: .local/pg_password}
database_url: {file: .local/database_url}
cache_url: {file: .local/cache_url}
valkey_conf: {file: .local/valkey.conf}
s3_access: {file: .local/s3_access}
s3_secret: {file: .local/s3_secret}
s3_root: {file: .local/s3_root}
s3_credentials: {file: .local/s3_credentials}