503 lines
13 KiB
YAML
503 lines
13 KiB
YAML
name: mtusi-lab6-maslov
|
|
services:
|
|
postgres:
|
|
image: postgres:18.3@sha256:7e32e9833a6fb1c92c32552794cb6ed569d51b445a54907d35fc112ef39684db
|
|
environment:
|
|
POSTGRES_USER: messenger
|
|
POSTGRES_DB: messenger
|
|
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
|
PGDATA: /var/lib/postgresql/data/pgdata
|
|
secrets:
|
|
- postgres_password
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql
|
|
healthcheck:
|
|
test:
|
|
- CMD-SHELL
|
|
- pg_isready -U messenger -d messenger
|
|
interval: 2s
|
|
timeout: 2s
|
|
retries: 20
|
|
cpus: 1
|
|
mem_limit: 512m
|
|
memswap_limit: 512m
|
|
cache:
|
|
image: valkey/valkey:8.1.3@sha256:fea8b3e67b15729d4bb70589eb03367bab9ad1ee89c876f54327fc7c6e618571
|
|
command:
|
|
- valkey-server
|
|
- /run/secrets/valkey.conf
|
|
secrets:
|
|
- cache_password
|
|
- source: valkey_config
|
|
target: valkey.conf
|
|
healthcheck:
|
|
test:
|
|
- CMD-SHELL
|
|
- REDISCLI_AUTH="$$(cat /run/secrets/cache_password)" valkey-cli ping
|
|
interval: 2s
|
|
timeout: 2s
|
|
retries: 20
|
|
cpus: 0.25
|
|
mem_limit: 128m
|
|
memswap_limit: 128m
|
|
migrate:
|
|
image: ${API_IMAGE:-mtusi-messenger:lab6}
|
|
pull_policy: never
|
|
command:
|
|
- python
|
|
- -m
|
|
- src.migrate
|
|
environment:
|
|
DATABASE_URL_FILE: /run/secrets/database_url
|
|
secrets:
|
|
- database_url
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
cpus: 0.5
|
|
mem_limit: 256m
|
|
read_only: true
|
|
api:
|
|
image: ${API_IMAGE:-mtusi-messenger:lab6}
|
|
build:
|
|
context: .
|
|
args:
|
|
VCS_REF: ${VCS_REF:-unknown}
|
|
scale: ${API_REPLICAS:-2}
|
|
environment:
|
|
APP_HOST: 0.0.0.0
|
|
APP_PORT: 8080
|
|
DATABASE_URL_FILE: /run/secrets/database_url
|
|
CACHE_URL_FILE: /run/secrets/cache_url
|
|
S3_ACCESS_KEY_FILE: /run/secrets/s3_access_key
|
|
S3_SECRET_KEY_FILE: /run/secrets/s3_secret_key
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
DB_POOL_SIZE: ${DB_POOL_SIZE:-10}
|
|
OTEL_ENABLED: ${OTEL_ENABLED:-1}
|
|
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel:4318
|
|
APP_VERSION: ${VCS_REF:-development}
|
|
secrets:
|
|
- database_url
|
|
- cache_url
|
|
- s3_access_key
|
|
- s3_secret_key
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
cache:
|
|
condition: service_healthy
|
|
s3-bootstrap:
|
|
condition: service_completed_successfully
|
|
cpus: ${API_CPUS:-0.5}
|
|
mem_limit: ${API_MEMORY:-384m}
|
|
memswap_limit: ${API_MEMORY:-384m}
|
|
pids_limit: 128
|
|
read_only: true
|
|
tmpfs:
|
|
- /tmp:rw,noexec,nosuid,size=128m
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
stop_grace_period: 10s
|
|
s3:
|
|
image: ${S3_IMAGE:-mtusi-storage:minio-20251015}
|
|
build:
|
|
context: .
|
|
dockerfile: infra/s3.Dockerfile
|
|
target: server
|
|
secrets:
|
|
- s3_root_user
|
|
- s3_root_password
|
|
volumes:
|
|
- s3_data:/data
|
|
cpus: 1
|
|
mem_limit: 1024m
|
|
memswap_limit: 1024m
|
|
read_only: true
|
|
tmpfs:
|
|
- /tmp:rw,nosuid,size=32m
|
|
environment:
|
|
HOME: /tmp
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
s3-bootstrap:
|
|
image: ${MC_IMAGE:-mtusi-storage:mc-20250813}
|
|
build:
|
|
context: .
|
|
dockerfile: infra/s3.Dockerfile
|
|
target: bootstrap
|
|
secrets:
|
|
- s3_root_user
|
|
- s3_root_password
|
|
- s3_access_key
|
|
- s3_secret_key
|
|
depends_on:
|
|
s3:
|
|
condition: service_healthy
|
|
cpus: 0.25
|
|
mem_limit: 128m
|
|
read_only: true
|
|
tmpfs:
|
|
- /tmp:rw,nosuid,size=16m
|
|
reconciler:
|
|
image: ${API_IMAGE:-mtusi-messenger:lab6}
|
|
pull_policy: never
|
|
command:
|
|
- python
|
|
- -m
|
|
- src.reconcile
|
|
- --apply
|
|
- --loop
|
|
environment:
|
|
DATABASE_URL_FILE: /run/secrets/database_url
|
|
S3_ACCESS_KEY_FILE: /run/secrets/s3_access_key
|
|
S3_SECRET_KEY_FILE: /run/secrets/s3_secret_key
|
|
STAGING_RETENTION_SECONDS: ${STAGING_RETENTION_SECONDS:-86400}
|
|
secrets:
|
|
- database_url
|
|
- s3_access_key
|
|
- s3_secret_key
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
s3-bootstrap:
|
|
condition: service_completed_successfully
|
|
cpus: 0.25
|
|
mem_limit: 256m
|
|
memswap_limit: 256m
|
|
read_only: true
|
|
healthcheck:
|
|
disable: true
|
|
broker:
|
|
image: valkey/valkey:8.1.3@sha256:fea8b3e67b15729d4bb70589eb03367bab9ad1ee89c876f54327fc7c6e618571
|
|
command:
|
|
- valkey-server
|
|
- /run/secrets/broker.conf
|
|
secrets:
|
|
- broker_password
|
|
- source: broker_config
|
|
target: broker.conf
|
|
volumes:
|
|
- broker_data:/data
|
|
healthcheck:
|
|
test:
|
|
- CMD-SHELL
|
|
- REDISCLI_AUTH="$$(cat /run/secrets/broker_password)" valkey-cli ping
|
|
interval: 2s
|
|
timeout: 2s
|
|
retries: 20
|
|
cpus: 0.5
|
|
mem_limit: 256m
|
|
memswap_limit: 256m
|
|
relay:
|
|
image: ${API_IMAGE:-mtusi-messenger:lab6}
|
|
pull_policy: never
|
|
command:
|
|
- python
|
|
- -m
|
|
- src.pipeline
|
|
environment:
|
|
DATABASE_URL_FILE: /run/secrets/database_url
|
|
BROKER_URL_FILE: /run/secrets/broker_url
|
|
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5}
|
|
OTEL_ENABLED: ${OTEL_ENABLED:-1}
|
|
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel:4318
|
|
APP_VERSION: ${VCS_REF:-development}
|
|
secrets:
|
|
- database_url
|
|
- broker_url
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
broker:
|
|
condition: service_healthy
|
|
cpus: 0.25
|
|
mem_limit: 192m
|
|
memswap_limit: 192m
|
|
read_only: true
|
|
healthcheck:
|
|
disable: true
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
worker:
|
|
image: ${API_IMAGE:-mtusi-messenger:lab6}
|
|
pull_policy: never
|
|
command:
|
|
- python
|
|
- -m
|
|
- src.worker
|
|
environment:
|
|
DATABASE_URL_FILE: /run/secrets/database_url
|
|
BROKER_URL_FILE: /run/secrets/broker_url
|
|
S3_ACCESS_KEY_FILE: /run/secrets/s3_access_key
|
|
S3_SECRET_KEY_FILE: /run/secrets/s3_secret_key
|
|
WORKER_CONCURRENCY: ${WORKER_CONCURRENCY:-2}
|
|
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5}
|
|
JOB_TIMEOUT_SECONDS: ${JOB_TIMEOUT_SECONDS:-20}
|
|
JOB_LEASE_SECONDS: ${JOB_LEASE_SECONDS:-23}
|
|
OTEL_ENABLED: ${OTEL_ENABLED:-1}
|
|
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel:4318
|
|
APP_VERSION: ${VCS_REF:-development}
|
|
secrets:
|
|
- database_url
|
|
- broker_url
|
|
- s3_access_key
|
|
- s3_secret_key
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
broker:
|
|
condition: service_healthy
|
|
s3-bootstrap:
|
|
condition: service_completed_successfully
|
|
cpus: 2
|
|
mem_limit: 1536m
|
|
memswap_limit: 1536m
|
|
pids_limit: 128
|
|
read_only: true
|
|
tmpfs:
|
|
- /tmp:rw,noexec,nosuid,size=64m
|
|
healthcheck:
|
|
disable: true
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
stop_grace_period: 25s
|
|
lb:
|
|
image: haproxy:3.2.1-alpine@sha256:ac79fe145f2bb6626ff26b584a2d0a34e791906c01015f2ae037aa3137b683d9
|
|
ports:
|
|
- 127.0.0.1:${PUBLIC_PORT:-8086}:8080
|
|
volumes:
|
|
- ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
|
depends_on:
|
|
api:
|
|
condition: service_healthy
|
|
cpus: 0.5
|
|
mem_limit: 128m
|
|
memswap_limit: 128m
|
|
read_only: true
|
|
tmpfs:
|
|
- /tmp:rw,nosuid,size=4m
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
stop_grace_period: 10s
|
|
observer:
|
|
image: ${API_IMAGE:-mtusi-messenger:lab6}
|
|
pull_policy: never
|
|
command:
|
|
- python
|
|
- -m
|
|
- src.observer
|
|
environment:
|
|
DATABASE_URL_FILE: /run/secrets/database_url
|
|
OTEL_ENABLED: ${OTEL_ENABLED:-1}
|
|
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel:4318
|
|
APP_VERSION: ${VCS_REF:-development}
|
|
secrets:
|
|
- database_url
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
cpus: 0.25
|
|
mem_limit: 192m
|
|
memswap_limit: 192m
|
|
read_only: true
|
|
healthcheck:
|
|
disable: true
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
otel:
|
|
image: otel/opentelemetry-collector-contrib:0.165.0@sha256:e40d61f10c9a617cca1ffd1be4d7e2b3a4b0f0001798ff07e58cabe82e618cea
|
|
user: 10001:10001
|
|
volumes:
|
|
- ./infra/otel/collector.yaml:/etc/otel/config.yaml:ro
|
|
cpus: 0.5
|
|
mem_limit: 384m
|
|
memswap_limit: 384m
|
|
environment:
|
|
GOMEMLIMIT: 224MiB
|
|
read_only: true
|
|
tmpfs:
|
|
- /tmp:rw,noexec,nosuid,size=32m
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
pids_limit: 128
|
|
command:
|
|
- --config=/etc/otel/config.yaml
|
|
prometheus:
|
|
image: prom/prometheus:v3.16.0@sha256:e04987641b57704f408e31f6373ba4138ecf27cb4a165d24aabb6c38fddd0f06
|
|
user: 65534:65534
|
|
volumes:
|
|
- ./infra/otel/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro
|
|
- ./infra/otel/alerts.yaml:/etc/prometheus/alerts.yaml:ro
|
|
- prometheus_data:/prometheus
|
|
cpus: 0.5
|
|
mem_limit: 384m
|
|
memswap_limit: 384m
|
|
read_only: true
|
|
tmpfs:
|
|
- /tmp:rw,noexec,nosuid,size=32m
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
pids_limit: 128
|
|
command:
|
|
- --config.file=/etc/prometheus/prometheus.yaml
|
|
- --storage.tsdb.path=/prometheus
|
|
- --storage.tsdb.retention.time=24h
|
|
- --storage.tsdb.retention.size=256MB
|
|
depends_on:
|
|
telemetry-init:
|
|
condition: service_completed_successfully
|
|
loki:
|
|
image: grafana/loki:3.7.10@sha256:b43c257ccfc925d4a50b8717cac61a3b51df8c48d01847936057e5c4075a24a7
|
|
user: 10001:10001
|
|
volumes:
|
|
- ./infra/otel/loki.yaml:/etc/loki/config.yaml:ro
|
|
- loki_data:/loki
|
|
cpus: 0.5
|
|
mem_limit: 384m
|
|
memswap_limit: 384m
|
|
read_only: true
|
|
tmpfs:
|
|
- /tmp:rw,noexec,nosuid,size=32m
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
pids_limit: 128
|
|
command:
|
|
- -config.file=/etc/loki/config.yaml
|
|
depends_on:
|
|
telemetry-init:
|
|
condition: service_completed_successfully
|
|
tempo:
|
|
image: grafana/tempo:3.1.1@sha256:64e2fbd56d9c2b3412a4b430a58ea59e91a670b1e75f920a0c702213ad145044
|
|
user: 10001:10001
|
|
volumes:
|
|
- ./infra/otel/tempo.yaml:/etc/tempo/config.yaml:ro
|
|
- tempo_data:/var/tempo
|
|
cpus: 0.5
|
|
mem_limit: 768m
|
|
memswap_limit: 768m
|
|
environment:
|
|
GOMEMLIMIT: 384MiB
|
|
read_only: true
|
|
tmpfs:
|
|
- /tmp:rw,noexec,nosuid,size=32m
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
pids_limit: 128
|
|
command:
|
|
- -config.file=/etc/tempo/config.yaml
|
|
depends_on:
|
|
telemetry-init:
|
|
condition: service_completed_successfully
|
|
grafana:
|
|
image: grafana/grafana:13.3.1@sha256:0615ec4fbd4072004b7d86b46ded63013a74b7d6eb1119273dd89e8fa25c13cf
|
|
user: 472:472
|
|
volumes:
|
|
- ./infra/grafana/provisioning:/etc/grafana/provisioning:ro
|
|
- ./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro
|
|
- grafana_data:/var/lib/grafana
|
|
cpus: 0.5
|
|
mem_limit: 384m
|
|
memswap_limit: 384m
|
|
read_only: true
|
|
tmpfs:
|
|
- /tmp:rw,noexec,nosuid,size=32m
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
pids_limit: 128
|
|
environment:
|
|
GF_SECURITY_ADMIN_USER: admin
|
|
GF_SECURITY_ADMIN_PASSWORD__FILE: /run/secrets/grafana_password
|
|
GF_AUTH_ANONYMOUS_ENABLED: 'false'
|
|
GF_USERS_ALLOW_SIGN_UP: 'false'
|
|
GF_ANALYTICS_REPORTING_ENABLED: 'false'
|
|
GF_ANALYTICS_CHECK_FOR_UPDATES: 'false'
|
|
GF_ANALYTICS_CHECK_FOR_PLUGIN_UPDATES: 'false'
|
|
GF_PLUGINS_PREINSTALL_DISABLED: 'true'
|
|
GF_LOG_LEVEL: warn
|
|
GOMEMLIMIT: 256MiB
|
|
secrets:
|
|
- grafana_password
|
|
ports:
|
|
- 127.0.0.1:${GRAFANA_PORT:-3006}:3000
|
|
depends_on:
|
|
telemetry-init:
|
|
condition: service_completed_successfully
|
|
telemetry-init:
|
|
image: ${API_IMAGE:-mtusi-messenger:lab6}
|
|
pull_policy: never
|
|
user: 0:0
|
|
command:
|
|
- python
|
|
- -c
|
|
- import os; [(os.makedirs(p,exist_ok=True),os.chown(p,u,u)) for p,u in [('/data/prometheus',65534),('/data/loki',10001),('/data/tempo',10001),('/data/grafana',472)]]
|
|
volumes:
|
|
- prometheus_data:/data/prometheus
|
|
- loki_data:/data/loki
|
|
- tempo_data:/data/tempo
|
|
- grafana_data:/data/grafana
|
|
read_only: true
|
|
cap_drop:
|
|
- ALL
|
|
cap_add:
|
|
- CHOWN
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
cpus: 0.1
|
|
mem_limit: 64m
|
|
healthcheck:
|
|
disable: true
|
|
secrets:
|
|
broker_password:
|
|
file: ./secrets/broker_password
|
|
broker_url:
|
|
file: ./secrets/broker_url
|
|
broker_config:
|
|
file: ./secrets/broker.conf
|
|
s3_root_user:
|
|
file: ./secrets/s3_root_user
|
|
s3_root_password:
|
|
file: ./secrets/s3_root_password
|
|
s3_access_key:
|
|
file: ./secrets/s3_access_key
|
|
s3_secret_key:
|
|
file: ./secrets/s3_secret_key
|
|
postgres_password:
|
|
file: ./secrets/postgres_password
|
|
database_url:
|
|
file: ./secrets/database_url
|
|
cache_password:
|
|
file: ./secrets/cache_password
|
|
cache_url:
|
|
file: ./secrets/cache_url
|
|
valkey_config:
|
|
file: ./secrets/valkey.conf
|
|
name: valkey.conf
|
|
grafana_password:
|
|
file: ./secrets/grafana_password
|
|
volumes:
|
|
broker_data: null
|
|
s3_data: null
|
|
postgres_data: null
|
|
prometheus_data: null
|
|
loki_data: null
|
|
tempo_data: null
|
|
grafana_data: null
|