Files
mtusi2026lab4/compose.yaml
T

103 lines
3.3 KiB
YAML

x-app: &app
image: mtusi-messenger:lab4
env_file: .env.api
cpus: 1.0
mem_limit: 256m
pids_limit: 64
read_only: true
cap_drop: [ALL]
security_opt: [no-new-privileges:true]
stop_grace_period: 35s
logging:
driver: json-file
options: {max-size: 5m, max-file: "2"}
services:
db:
image: mirror.gcr.io/library/postgres@sha256:3645570cccdfa447589da9f57dd740faa29b30938e861289a5574b6ca6b03826
environment:
POSTGRES_USER: messenger
POSTGRES_DB: messenger
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Run python scripts/bootstrap.py}
command: [postgres, -c, shared_buffers=64MB, -c, max_connections=30]
volumes: [pgdata:/var/lib/postgresql/data]
cpus: 1.0
mem_limit: 256m
healthcheck:
test: [CMD-SHELL, "pg_isready -U messenger -d messenger"]
interval: 2s
timeout: 2s
retries: 20
cache:
image: mirror.gcr.io/valkey/valkey@sha256:081c2f5cb575efc901aa80ff9cdbd1ec6a301682fd35e1ebb4b0990a4a4a8507
command: [valkey-server, --maxmemory, 32mb, --maxmemory-policy, allkeys-lru, --save, "", --appendonly, "no"]
cpus: 0.25
mem_limit: 64m
healthcheck:
test: [CMD, valkey-cli, ping]
interval: 2s
timeout: 1s
retries: 20
migrate:
<<: *app
command: [python, -m, src.migrate]
healthcheck: {disable: true}
depends_on:
db: {condition: service_healthy}
api:
<<: *app
build: .
deploy:
replicas: 2
cpus: 0.5
mem_limit: 512m
tmpfs: ["/tmp:size=32m,mode=1777"]
depends_on:
migrate: {condition: service_completed_successfully}
cache: {condition: service_healthy}
storage-init: {condition: service_completed_successfully}
s3:
image: mirror.gcr.io/chrislusf/seaweedfs@sha256:4e61d15fd35994cb1e43e1e553dff106794841fd9a99ade2fc8c8bfce4d7872d
user: "1000:1000"
command: [server, -dir=/data, -ip=127.0.0.1, -ip.bind=127.0.0.1, -s3, -s3.ip.bind=0.0.0.0, -s3.config=/etc/seaweedfs/s3.json, -s3.port.iceberg=0, -s3.port.lance=0, -s3.autoCreateBucket=false, -volume.max=10, -master.volumeSizeLimitMB=100, -filer.concurrentUploadLimitMB=64]
environment: {GOMEMLIMIT: 384MiB, GOMAXPROCS: "2"}
volumes: ["s3data:/data", "./secrets/s3.json:/etc/seaweedfs/s3.json:ro"]
cpus: 1.0
mem_limit: 512m
cap_drop: [ALL]
security_opt: [no-new-privileges:true]
stop_grace_period: 20s
storage-init:
<<: *app
env_file: .env.storage-admin
command: [python, -m, src.bootstrap_storage]
healthcheck: {disable: true}
depends_on: [s3]
reconciler:
<<: *app
cpus: 0.25
mem_limit: 192m
command: [python, -m, src.reconcile_loop]
healthcheck:
test: [CMD, python, -c, "import os; os.kill(1,0)"]
interval: 10s
timeout: 2s
start_period: 5s
retries: 3
depends_on:
migrate: {condition: service_completed_successfully}
storage-init: {condition: service_completed_successfully}
lb:
image: mirror.gcr.io/library/haproxy@sha256:d84eb36e91830bcaa67b23cfde1909850b99f11eb60da3abd185bd0daf3f75bb
ports: ["127.0.0.1:8080:8080"]
volumes: ["./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro"]
cpus: 0.5
mem_limit: 64m
read_only: true
cap_drop: [ALL]
security_opt: [no-new-privileges:true]
depends_on:
api: {condition: service_healthy}
volumes:
pgdata:
s3data: