Files
mtusi2026lab6/compose.yaml
T

208 lines
7.6 KiB
YAML

x-app: &app
image: mtusi-messenger:lab6
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:
telemetry-init:
<<: *app
user: "0:0"
cap_add: [CHOWN, FOWNER]
command: [python, -c, "import os; [(os.chown(p,u,u),os.chmod(p,0o750)) for p,u in [('/grafana',472),('/prometheus',65534),('/loki',10001),('/tempo',10001)]]"]
healthcheck: {disable: true}
volumes: [grafanadata:/grafana, prometheusdata:/prometheus, lokidata:/loki, tempodata:/tempo]
otel-collector:
image: mirror.gcr.io/otel/opentelemetry-collector-contrib@sha256:ffc818ee108d0b934fd14207fd87ff247c9b64f344ed349d0b66c166c18a2312
command: [--config=/etc/otel/config.yaml]
volumes: ["./infra/otel-collector.yaml:/etc/otel/config.yaml:ro"]
mem_limit: 256m
cpus: 0.5
environment: {GOMEMLIMIT: 192MiB, GOMAXPROCS: "2"}
read_only: true
cap_drop: [ALL]
prometheus:
image: mirror.gcr.io/prom/prometheus@sha256:efd719c99d83b060d9daefdcf00360461adf279f45ef5391f8d111892118753e
command: [--config.file=/etc/prometheus/prometheus.yaml, --storage.tsdb.path=/prometheus, --storage.tsdb.retention.time=24h, --storage.tsdb.retention.size=256MB]
volumes: ["./infra/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro", "./infra/alerts.yaml:/etc/prometheus/alerts.yaml:ro", "prometheusdata:/prometheus"]
ports: ["127.0.0.1:9090:9090"]
mem_limit: 256m
cpus: 0.5
depends_on:
telemetry-init: {condition: service_completed_successfully}
loki:
image: mirror.gcr.io/grafana/loki@sha256:3c8fd3570dd9219951a60d3f919c7f31923d10baee578b77bc26c4a0b32d092d
command: [-config.file=/etc/loki/config.yaml]
volumes: ["./infra/loki.yaml:/etc/loki/config.yaml:ro", "lokidata:/var/loki"]
ports: ["127.0.0.1:3100:3100"]
mem_limit: 256m
cpus: 0.5
environment: {GOMEMLIMIT: 192MiB, GOMAXPROCS: "2"}
depends_on:
telemetry-init: {condition: service_completed_successfully}
tempo:
image: mirror.gcr.io/grafana/tempo@sha256:d7f4c72e0bad2b42b4e7263b0addaf3f5bbc105cec6b1917eba0aae3b9b70364
command: [-config.file=/etc/tempo/config.yaml]
volumes: ["./infra/tempo.yaml:/etc/tempo/config.yaml:ro", "tempodata:/var/tempo"]
ports: ["127.0.0.1:3200:3200"]
mem_limit: 256m
cpus: 0.5
environment: {GOMEMLIMIT: 192MiB, GOMAXPROCS: "2"}
depends_on:
telemetry-init: {condition: service_completed_successfully}
grafana:
image: mirror.gcr.io/grafana/grafana@sha256:dbbc38ea21103cefb50396340cd88afec779c7e070b0a7bf5a75b4ce46651d3f
environment:
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD__FILE: /run/secrets/grafana-password
GF_USERS_ALLOW_SIGN_UP: "false"
GF_ANALYTICS_REPORTING_ENABLED: "false"
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
GOMEMLIMIT: 384MiB
GOMAXPROCS: "2"
volumes: ["grafanadata:/var/lib/grafana", "./infra/grafana/provisioning:/etc/grafana/provisioning:ro", "./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro", "./secrets/grafana-password:/run/secrets/grafana-password:ro"]
ports: ["127.0.0.1:3000:3000"]
mem_limit: 512m
cpus: 1.0
depends_on:
telemetry-init: {condition: service_completed_successfully}
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
env_file: .env.worker
cpus: 0.25
mem_limit: 192m
command: [python, -m, src.cleanup]
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}
broker:
image: mirror.gcr.io/valkey/valkey@sha256:081c2f5cb575efc901aa80ff9cdbd1ec6a301682fd35e1ebb4b0990a4a4a8507
command: [valkey-server, /etc/valkey/lab.conf]
volumes: ["brokerdata:/data", "./secrets/broker.conf:/etc/valkey/lab.conf:ro"]
cpus: 0.25
mem_limit: 128m
dispatcher:
<<: *app
env_file: .env.worker
cpus: 0.25
mem_limit: 128m
tmpfs: ["/tmp:size=32m,mode=1777"]
command: [python, -m, src.dispatcher]
healthcheck:
test: [CMD, python, -c, "import os; os.kill(1,0)"]
interval: 10s
timeout: 2s
start_period: 5s
depends_on:
migrate: {condition: service_completed_successfully}
broker: {condition: service_started}
worker:
<<: *app
env_file: .env.worker
cpus: 1.0
mem_limit: 768m
tmpfs: ["/tmp:size=64m,mode=1777"]
restart: on-failure:5
command: [python, -m, src.worker]
healthcheck:
test: [CMD, python, -c, "import os; os.kill(1,0)"]
interval: 10s
timeout: 2s
start_period: 5s
depends_on:
migrate: {condition: service_completed_successfully}
storage-init: {condition: service_completed_successfully}
broker: {condition: service_started}
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:
grafanadata:
prometheusdata:
lokidata:
tempodata:
pgdata:
s3data:
brokerdata: