Files
mtusi2026lab7/compose.yaml
T
kokorindenis a884c07867
Skeleton contracts / contracts (pull_request) Canceled after 0s
solution
2026-11-27 16:42:18 +03:00

895 lines
26 KiB
YAML

# Лабораторная 7: защищённый стенд.
#
# Публично опубликованы только Traefik :8443 (HTTPS) и локальные
# административные интерфейсы на 127.0.0.1 (Grafana, OpenBao, Prometheus).
# API-реплики не публикуют порт: единственный вход — Traefik, который идёт в
# mTLS-шлюз каждой реплики с клиентским сертификатом lb-client.
name: lab7
x-api-environment: &api-environment
APP_ENV: lab
APP_HOST: 127.0.0.1
APP_PORT: "8080"
GATEWAY_CONFIG: /etc/gateway/api.json
LOG_LEVEL: info
SESSION_TTL_SECONDS: "${SESSION_TTL_SECONDS:-3600}"
SESSION_STORE: postgres
DB_POOL_SIZE: "5"
DB_MAX_OVERFLOW: "5"
DB_POOL_TIMEOUT_SECONDS: "2"
DB_CONNECT_TIMEOUT_SECONDS: "1.5"
DB_COMMAND_TIMEOUT_SECONDS: "2.5"
DB_STATEMENT_TIMEOUT_MS: "2000"
DB_CA_FILE: /certs/ca.crt
S3_CA_FILE: /certs/ca.crt
BROKER_CA_FILE: /certs/ca.crt
BROKER_CLIENT_CERT_FILE: /certs/api-client.crt
BROKER_CLIENT_KEY_FILE: /certs/api-client.key
GRACEFUL_SHUTDOWN_SECONDS: "5"
SHUTDOWN_DRAIN_SECONDS: "2"
S3_REGION: us-east-1
S3_BUCKET: messenger-attachments
S3_KEY_PREFIX: "attachments/"
S3_CONNECT_TIMEOUT_SECONDS: "1.5"
S3_READ_TIMEOUT_SECONDS: "30"
S3_MAX_ATTEMPTS: "2"
MAX_UPLOAD_BYTES: "10485760"
MAX_IMAGE_PIXELS: "40000000"
ATTACHMENT_ORPHAN_GRACE_SECONDS: "3600"
STAGING_RETENTION_SECONDS: "86400"
ATTACHMENT_FAULT_MODE: none
PIPELINE_VERSION: "2"
JOB_MAX_ATTEMPTS: "5"
ALLOW_FAULT_INJECTION: "true"
ARGON2_MEMORY_KIB: "${ARGON2_MEMORY_KIB:-19456}"
ARGON2_ITERATIONS: "${ARGON2_ITERATIONS:-2}"
ARGON2_PARALLELISM: "${ARGON2_PARALLELISM:-1}"
LOGIN_RATE_LIMIT_ATTEMPTS: "${LOGIN_RATE_LIMIT_ATTEMPTS:-10}"
LOGIN_RATE_LIMIT_WINDOW_SECONDS: "60"
LOGIN_RATE_LIMIT_BLOCK_SECONDS: "60"
LOGIN_MAX_CONCURRENCY: "2"
SECRETS_FROM_BAO: "1"
BAO_ADDR: https://openbao:8200
BAO_CACERT: /certs/ca.crt
BAO_ROLE_ID_FILE: /run/bao/api_role_id
BAO_SECRET_ID_FILE: /run/bao/api_secret_id
BAO_SECRET_PATH: messenger/api
OTEL_SERVICE_NAME: messenger-api
OTEL_EXPORTER_OTLP_ENDPOINT: https://internal-gateway:4318
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
OTEL_EXPORTER_OTLP_CERTIFICATE: /certs/ca.crt
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE: /certs/api-client.crt
OTEL_EXPORTER_OTLP_CLIENT_KEY: /certs/api-client.key
OTEL_RESOURCE_ATTRIBUTES: deployment.environment.name=lab
OTEL_SDK_DISABLED: "false"
OTEL_TRACES_SAMPLER: parentbased_always_on
OTEL_TRACES_SAMPLER_ARG: "1.0"
x-worker-environment: &worker-environment
APP_ENV: lab
LOG_LEVEL: info
DB_POOL_SIZE: "3"
DB_MAX_OVERFLOW: "3"
DB_POOL_TIMEOUT_SECONDS: "2"
DB_CONNECT_TIMEOUT_SECONDS: "1.5"
DB_COMMAND_TIMEOUT_SECONDS: "5"
DB_STATEMENT_TIMEOUT_MS: "10000"
DB_CA_FILE: /certs/ca.crt
S3_CA_FILE: /certs/ca.crt
BROKER_CA_FILE: /certs/ca.crt
GRACEFUL_SHUTDOWN_SECONDS: "10"
S3_REGION: us-east-1
S3_BUCKET: messenger-attachments
S3_KEY_PREFIX: "attachments/"
S3_CONNECT_TIMEOUT_SECONDS: "1.5"
S3_READ_TIMEOUT_SECONDS: "60"
S3_MAX_ATTEMPTS: "3"
MAX_UPLOAD_BYTES: "10485760"
MAX_IMAGE_PIXELS: "40000000"
PIPELINE_VERSION: "2"
WORKER_CONCURRENCY: "${WORKER_CONCURRENCY:-2}"
WORKER_PREFETCH: "${WORKER_PREFETCH:-2}"
JOB_MAX_ATTEMPTS: "${JOB_MAX_ATTEMPTS:-5}"
JOB_TIMEOUT_SECONDS: "${JOB_TIMEOUT_SECONDS:-60}"
JOB_LEASE_SECONDS: "${JOB_LEASE_SECONDS:-15}"
JOB_BACKOFF_BASE_SECONDS: "1"
JOB_BACKOFF_MAX_SECONDS: "30"
STAGING_RETENTION_SECONDS: "86400"
ALLOW_FAULT_INJECTION: "true"
RELAY_POLL_SECONDS: "0.25"
REAPER_INTERVAL_SECONDS: "1"
SECRETS_FROM_BAO: "1"
BAO_ADDR: https://openbao:8200
BAO_CACERT: /certs/ca.crt
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
OTEL_RESOURCE_ATTRIBUTES: deployment.environment.name=lab
OTEL_SDK_DISABLED: "false"
OTEL_TRACES_SAMPLER: parentbased_always_on
OTEL_TRACES_SAMPLER_ARG: "1.0"
services:
traefik:
image: traefik:v3.5.4@sha256:4df0a50fcf71b454c0d7ad17675776dc8d37359deae3291895bdaa008c1b9972
command:
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --providers.docker.network=lab7_edge
- --providers.docker.watch=true
- --providers.docker.endpoint=unix:///var/run/docker.sock
- --providers.file.filename=/etc/traefik/dynamic.yml
- --entryPoints.websecure.address=:8443
- --log.level=INFO
- --accesslog=false
ports:
- target: 8443
published: 8443
protocol: tcp
host_ip: 127.0.0.1
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./infra/traefik/dynamic.yml:/etc/traefik/dynamic.yml:ro
- ./secrets/certs/traefik:/certs:ro
networks: [edge]
read_only: true
tmpfs: [/tmp]
security_opt: ["no-new-privileges:true"]
cap_drop: [ALL]
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "0.50"
memory: 128M
postgres:
image: postgres:16.15-bookworm@sha256:0ea6700a3b4f0ae6ce746519073558aed4d88a79d8d07622a9a644946c7319c4
entrypoint: ["/bin/sh", "/etc/postgres-entrypoint.sh"]
environment:
POSTGRES_USER: messenger
POSTGRES_DB: messenger
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256"
secrets: [postgres_password]
volumes:
- pgdata:/var/lib/postgresql/data
- ./infra/postgres/pg_hba.conf:/etc/postgresql/pg_hba.conf:ro
- ./infra/postgres/entrypoint.sh:/etc/postgres-entrypoint.sh:ro
- ./secrets/certs/postgres:/certs:ro
networks: [data]
healthcheck:
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"]
interval: 5s
timeout: 3s
retries: 12
start_period: 10s
security_opt: ["no-new-privileges:true"]
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "2.0"
memory: 512M
db-roles:
image: postgres:16.15-bookworm@sha256:0ea6700a3b4f0ae6ce746519073558aed4d88a79d8d07622a9a644946c7319c4
entrypoint: ["/bin/sh", "/etc/db-init.sh", "roles"]
environment:
PGHOST: postgres
PGUSER: messenger
PGDATABASE: messenger
secrets:
- postgres_password
- db_api_password
- db_worker_password
- db_relay_password
volumes:
- ./scripts/db-init.sh:/etc/db-init.sh:ro
networks: [data]
depends_on:
postgres:
condition: service_healthy
restart: "no"
deploy:
replicas: 1
resources:
limits:
cpus: "0.5"
memory: 128M
migrate:
image: ${API_IMAGE:-mtusi-messenger-lab7:7.0.0}
build:
context: .
command:
- /bin/sh
- -c
- "until alembic upgrade head; do echo migration waiting for postgres; sleep 2; done"
environment:
SECRETS_FROM_BAO: "0"
DATABASE_URL_FILE: /run/secrets/migrate_database_url
DB_CA_FILE: /certs/ca.crt
secrets:
- migrate_database_url
volumes:
- ./secrets/certs/postgres:/certs:ro
networks: [data]
depends_on:
db-roles:
condition: service_completed_successfully
restart: "no"
deploy:
replicas: 1
resources:
limits:
cpus: "1.0"
memory: 256M
db-grants:
image: postgres:16.15-bookworm@sha256:0ea6700a3b4f0ae6ce746519073558aed4d88a79d8d07622a9a644946c7319c4
entrypoint: ["/bin/sh", "/etc/db-init.sh", "grants"]
environment:
PGHOST: postgres
PGUSER: messenger
PGDATABASE: messenger
secrets:
- postgres_password
- db_api_password
- db_worker_password
- db_relay_password
volumes:
- ./scripts/db-init.sh:/etc/db-init.sh:ro
networks: [data]
depends_on:
migrate:
condition: service_completed_successfully
restart: "no"
deploy:
replicas: 1
resources:
limits:
cpus: "0.5"
memory: 128M
minio:
image: minio/minio@sha256:14cea493d9a34af32f524e538b8346cf79f3321eff8e708c1e2960462bd8936e
entrypoint: ["/bin/sh", "-c"]
command:
- >-
export MINIO_ROOT_USER=$$(cat /run/secrets/minio_root_user);
export MINIO_ROOT_PASSWORD=$$(cat /run/secrets/minio_root_password);
exec /usr/bin/minio server /data --certs-dir /certs --console-address :9001
environment:
MINIO_BROWSER: "off"
MINIO_SERVER_URL: "https://minio:9000"
secrets: [minio_root_user, minio_root_password]
volumes:
- miniodata:/data
- ./secrets/certs/minio:/certs:ro
networks: [data]
healthcheck:
test: ["CMD", "curl", "-fsS", "--cacert", "/certs/ca.crt", "https://127.0.0.1:9000/minio/health/live"]
interval: 5s
timeout: 3s
retries: 12
start_period: 10s
security_opt: ["no-new-privileges:true"]
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "1.0"
memory: 512M
minio-init:
image: minio/minio@sha256:14cea493d9a34af32f524e538b8346cf79f3321eff8e708c1e2960462bd8936e
entrypoint: ["/bin/sh", "/etc/minio-init.sh"]
environment:
S3_CA_FILE: /certs/ca.crt
MC_CONFIG_DIR: /tmp/.mc
secrets:
- minio_root_user
- minio_root_password
- s3_api_access_key
- s3_api_secret_key
- s3_worker_access_key
- s3_worker_secret_key
volumes:
- ./scripts/minio-init.sh:/etc/minio-init.sh:ro
- ./secrets/certs/minio:/certs:ro
networks: [data]
depends_on:
minio:
condition: service_healthy
restart: "no"
deploy:
replicas: 1
resources:
limits:
cpus: "0.5"
memory: 128M
rabbitmq:
image: rabbitmq:4.1.4-alpine@sha256:b736d649308e1b3e1a116c3f36986b605ee3d03e88f10166be2900083d2e63f2
entrypoint: ["/bin/sh", "-c"]
command:
- >-
export RABBITMQ_DEFAULT_USER=$$(cat /run/secrets/rabbitmq_root_user);
export RABBITMQ_DEFAULT_PASS=$$(cat /run/secrets/rabbitmq_root_password);
exec docker-entrypoint.sh rabbitmq-server
environment:
RABBITMQ_NODENAME: "rabbit@localhost"
RABBITMQ_USE_LONGNAME: "false"
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: "+S 2:2"
secrets: [rabbitmq_root_user, rabbitmq_root_password]
volumes:
- rabbitmqdata:/var/lib/rabbitmq
- ./infra/rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro
- ./secrets/certs/rabbitmq:/certs:ro
networks: [broker]
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]
interval: 10s
timeout: 5s
retries: 18
start_period: 30s
security_opt: ["no-new-privileges:true"]
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "1.0"
memory: 512M
openbao:
image: openbao/openbao:2.3.2@sha256:afec9f65a7067a22acf24b29f07d2f028353c02cc0fa9c80dfa4e7fab158b373
entrypoint: ["/bin/sh", "/etc/openbao-entrypoint.sh"]
volumes:
- openbaodata:/openbao/data
- ./infra/openbao/config.hcl:/openbao/config.hcl:ro
- ./infra/openbao/entrypoint.sh:/etc/openbao-entrypoint.sh:ro
- ./secrets/certs/openbao:/certs:ro
ports:
- target: 8200
published: 8200
host_ip: 127.0.0.1
protocol: tcp
networks: [data, admin]
read_only: true
tmpfs: [/tmp]
security_opt: ["no-new-privileges:true"]
cap_drop: [ALL]
cap_add: [SETUID, SETGID, CHOWN, DAC_OVERRIDE]
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "1.0"
memory: 256M
openbao-bootstrap:
image: ${API_IMAGE:-mtusi-messenger-lab7:7.0.0}
build:
context: .
# bootstrap пишет в host secrets/; root только для записи, app — uid 10001.
user: "0:0"
command: ["python", "/app/scripts/openbao_bootstrap.py"]
environment:
BAO_ADDR: https://openbao:8200
BAO_CACERT: /certs/ca.crt
BOOTSTRAP_DIR: /bootstrap
BAO_TOKEN_TTL_SECONDS: "${BAO_TOKEN_TTL_SECONDS:-300}"
BAO_TOKEN_MAX_TTL_SECONDS: "${BAO_TOKEN_MAX_TTL_SECONDS:-900}"
BAO_SECRET_ID_TTL_SECONDS: "${BAO_SECRET_ID_TTL_SECONDS:-86400}"
volumes:
- ./scripts:/app/scripts:ro
- ./secrets:/bootstrap
- ./secrets/certs/openbao:/certs:ro
networks: [data]
depends_on:
openbao:
condition: service_started
restart: "no"
deploy:
replicas: 1
resources:
limits:
cpus: "0.5"
memory: 128M
internal-gateway:
image: ${API_IMAGE:-mtusi-messenger-lab7:7.0.0}
build:
context: .
command: ["python", "-m", "messenger.mtls_gateway", "--config", "/etc/gateway/internal.json"]
volumes:
- ./infra/gateway/internal.json:/etc/gateway/internal.json:ro
- ./secrets/certs/gateway:/certs:ro
networks: [app, broker, otelnet]
read_only: true
tmpfs: [/tmp]
security_opt: ["no-new-privileges:true"]
cap_drop: [ALL]
healthcheck:
test: ["CMD-SHELL", "python -c \"import socket; s=socket.create_connection(('127.0.0.1',5671),2); s.close()\""]
interval: 10s
timeout: 3s
retries: 6
start_period: 5s
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "0.5"
memory: 128M
api:
image: ${API_IMAGE:-mtusi-messenger-lab7:7.0.0}
build:
context: .
command: ["/bin/sh", "/usr/local/bin/api-entrypoint.sh"]
environment:
<<: *api-environment
volumes:
- ./scripts/api-entrypoint.sh:/usr/local/bin/api-entrypoint.sh:ro
- ./infra/gateway/api.json:/etc/gateway/api.json:ro
- ./secrets/certs/api:/certs:ro
- ./secrets/bao_runtime:/run/bao:ro
networks: [edge, app, data]
stop_grace_period: 15s
healthcheck:
test: ["CMD", "python", "-m", "messenger.healthcheck"]
interval: 5s
timeout: 3s
start_period: 20s
retries: 3
depends_on:
migrate:
condition: service_completed_successfully
db-grants:
condition: service_completed_successfully
postgres:
condition: service_healthy
minio:
condition: service_healthy
openbao-bootstrap:
condition: service_completed_successfully
labels:
- traefik.enable=true
- traefik.docker.network=lab7_edge
- traefik.http.routers.messenger-lab7.rule=PathPrefix(`/`)
- traefik.http.routers.messenger-lab7.entrypoints=websecure
- traefik.http.routers.messenger-lab7.tls=true
- traefik.http.routers.messenger-lab7.service=messenger-lab7
- traefik.http.services.messenger-lab7.loadbalancer.server.port=8081
- traefik.http.services.messenger-lab7.loadbalancer.server.scheme=https
- traefik.http.services.messenger-lab7.loadbalancer.serverstransport=api-mtls@file
- traefik.http.services.messenger-lab7.loadbalancer.healthcheck.path=/health/ready
- traefik.http.services.messenger-lab7.loadbalancer.healthcheck.interval=2s
- traefik.http.services.messenger-lab7.loadbalancer.healthcheck.timeout=2s
- traefik.http.services.messenger-lab7.loadbalancer.healthcheck.scheme=https
read_only: true
tmpfs: [/tmp]
security_opt: ["no-new-privileges:true"]
cap_drop: [ALL]
restart: unless-stopped
deploy:
replicas: 2
resources:
limits:
cpus: "1.0"
memory: 512M
reservations:
cpus: "0.25"
memory: 128M
worker:
image: ${API_IMAGE:-mtusi-messenger-lab7:7.0.0}
build:
context: .
command: ["python", "-m", "messenger.worker"]
environment:
<<: *worker-environment
OTEL_SERVICE_NAME: messenger-worker
BAO_ROLE_ID_FILE: /run/bao/worker_role_id
BAO_SECRET_ID_FILE: /run/bao/worker_secret_id
BAO_SECRET_PATH: messenger/worker
BROKER_CLIENT_CERT_FILE: /certs/worker-client.crt
BROKER_CLIENT_KEY_FILE: /certs/worker-client.key
OTEL_EXPORTER_OTLP_ENDPOINT: https://internal-gateway:4319
OTEL_EXPORTER_OTLP_CERTIFICATE: /certs/ca.crt
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE: /certs/worker-client.crt
OTEL_EXPORTER_OTLP_CLIENT_KEY: /certs/worker-client.key
HEARTBEAT_FILE: /tmp/messenger-worker-heartbeat
volumes:
- ./secrets/certs/worker:/certs:ro
- ./secrets/bao_runtime:/run/bao:ro
networks: [app, data]
stop_grace_period: 20s
healthcheck:
test: ["CMD", "python", "-m", "messenger.worker_health"]
interval: 10s
timeout: 3s
start_period: 15s
retries: 3
depends_on:
db-grants:
condition: service_completed_successfully
postgres:
condition: service_healthy
minio:
condition: service_healthy
rabbitmq:
condition: service_healthy
openbao-bootstrap:
condition: service_completed_successfully
read_only: true
tmpfs: [/tmp]
security_opt: ["no-new-privileges:true"]
cap_drop: [ALL]
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "1.0"
memory: 512M
relay:
image: ${API_IMAGE:-mtusi-messenger-lab7:7.0.0}
build:
context: .
command: ["python", "-m", "messenger.relay"]
environment:
<<: *worker-environment
OTEL_SERVICE_NAME: messenger-relay
BAO_ROLE_ID_FILE: /run/bao/relay_role_id
BAO_SECRET_ID_FILE: /run/bao/relay_secret_id
BAO_SECRET_PATH: messenger/relay
BROKER_CLIENT_CERT_FILE: /certs/relay-client.crt
BROKER_CLIENT_KEY_FILE: /certs/relay-client.key
OTEL_EXPORTER_OTLP_ENDPOINT: https://internal-gateway:4320
OTEL_EXPORTER_OTLP_CERTIFICATE: /certs/ca.crt
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE: /certs/relay-client.crt
OTEL_EXPORTER_OTLP_CLIENT_KEY: /certs/relay-client.key
HEARTBEAT_FILE: /tmp/messenger-relay-heartbeat
volumes:
- ./secrets/certs/relay:/certs:ro
- ./secrets/bao_runtime:/run/bao:ro
networks: [app, data]
stop_grace_period: 15s
healthcheck:
test: ["CMD", "python", "-m", "messenger.worker_health"]
interval: 10s
timeout: 3s
start_period: 15s
retries: 3
depends_on:
db-grants:
condition: service_completed_successfully
postgres:
condition: service_healthy
rabbitmq:
condition: service_healthy
minio:
condition: service_healthy
openbao-bootstrap:
condition: service_completed_successfully
read_only: true
tmpfs: [/tmp]
security_opt: ["no-new-privileges:true"]
cap_drop: [ALL]
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "0.5"
memory: 256M
otel-collector:
image: otel/opentelemetry-collector-contrib:0.140.0
command: ["--config=/etc/otelcol/config.yaml"]
volumes:
- ./observability/otel-collector/config.yaml:/etc/otelcol/config.yaml:ro
- ./secrets/certs/telemetry:/certs:ro
networks: [otelnet, telemetry, collectorscrape]
depends_on:
tempo:
condition: service_started
loki:
condition: service_started
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "1.0"
memory: 512M
prometheus:
image: prom/prometheus:v3.7.3
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
- --storage.tsdb.retention.time=24h
- --web.enable-lifecycle
volumes:
- ./observability/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./observability/prometheus/rules:/etc/prometheus/rules:ro
- ./secrets/certs/telemetry:/certs:ro
- promdata:/prometheus
networks: [promnet, collectorscrape]
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://127.0.0.1:9090/-/healthy"]
interval: 10s
timeout: 3s
retries: 12
start_period: 10s
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "1.0"
memory: 512M
loki:
image: grafana/loki:3.6.2
command: ["-config.file=/etc/loki/local-config.yaml"]
volumes:
- ./observability/loki/loki-config.yaml:/etc/loki/local-config.yaml:ro
- lokidata:/loki
networks: [lokinet]
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "0.5"
memory: 384M
tempo:
image: grafana/tempo:2.9.0
command: ["-config.file=/etc/tempo.yaml"]
volumes:
- ./observability/tempo/tempo.yaml:/etc/tempo.yaml:ro
- tempodata:/var/tempo
networks: [temponet]
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "0.5"
memory: 384M
grafana:
image: grafana/grafana:12.2.0
environment:
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD__FILE: /run/secrets/grafana_admin_password
GF_USERS_ALLOW_SIGN_UP: "false"
GF_AUTH_ANONYMOUS_ENABLED: "true"
GF_AUTH_ANONYMOUS_ORG_ROLE: Viewer
GF_ANALYTICS_REPORTING_ENABLED: "false"
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
GF_SERVER_PROTOCOL: https
GF_SERVER_HTTP_PORT: "3000"
GF_SERVER_CERT_FILE: /certs/grafana.crt
GF_SERVER_CERT_KEY: /certs/grafana.key
secrets: [grafana_admin_password]
ports:
- "127.0.0.1:3000:3000"
volumes:
- ./observability/grafana/provisioning:/etc/grafana/provisioning:ro
- ./observability/grafana/dashboards:/var/lib/grafana/dashboards:ro
- ./secrets/certs/telemetry:/certs:ro
- grafanadata:/var/lib/grafana
networks: [telemetry, admin]
depends_on:
prometheus:
condition: service_started
loki:
condition: service_started
tempo:
condition: service_started
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "0.5"
memory: 384M
prometheus-tls:
image: ${API_IMAGE:-mtusi-messenger-lab7:7.0.0}
build:
context: .
command: ["python", "-m", "messenger.mtls_gateway", "--config", "/etc/gateway/tls.json"]
healthcheck:
disable: true
volumes:
- ./infra/gateway/prometheus-tls.json:/etc/gateway/tls.json:ro
- ./secrets/certs/telemetry:/certs:ro
networks: [promnet, telemetry]
read_only: true
tmpfs: [/tmp]
security_opt: ["no-new-privileges:true"]
cap_drop: [ALL]
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "0.25"
memory: 96M
loki-tls:
image: ${API_IMAGE:-mtusi-messenger-lab7:7.0.0}
build:
context: .
command: ["python", "-m", "messenger.mtls_gateway", "--config", "/etc/gateway/tls.json"]
healthcheck:
disable: true
volumes:
- ./infra/gateway/loki-tls.json:/etc/gateway/tls.json:ro
- ./secrets/certs/telemetry:/certs:ro
networks: [lokinet, telemetry]
read_only: true
tmpfs: [/tmp]
security_opt: ["no-new-privileges:true"]
cap_drop: [ALL]
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "0.25"
memory: 96M
tempo-tls:
image: ${API_IMAGE:-mtusi-messenger-lab7:7.0.0}
build:
context: .
command: ["python", "-m", "messenger.mtls_gateway", "--config", "/etc/gateway/tls.json"]
healthcheck:
disable: true
volumes:
- ./infra/gateway/tempo-tls.json:/etc/gateway/tls.json:ro
- ./secrets/certs/telemetry:/certs:ro
networks: [temponet, telemetry]
read_only: true
tmpfs: [/tmp]
security_opt: ["no-new-privileges:true"]
cap_drop: [ALL]
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "0.25"
memory: 96M
collector-tls:
image: ${API_IMAGE:-mtusi-messenger-lab7:7.0.0}
build:
context: .
command: ["python", "-m", "messenger.mtls_gateway", "--config", "/etc/gateway/tls.json"]
healthcheck:
disable: true
volumes:
- ./infra/gateway/collector-tls.json:/etc/gateway/tls.json:ro
- ./secrets/certs/telemetry:/certs:ro
networks: [collectorscrape, telemetry]
read_only: true
tmpfs: [/tmp]
security_opt: ["no-new-privileges:true"]
cap_drop: [ALL]
restart: unless-stopped
deploy:
replicas: 1
resources:
limits:
cpus: "0.25"
memory: 96M
security-probe:
image: ${API_IMAGE:-mtusi-messenger-lab7:7.0.0}
build:
context: .
command: ["sleep", "infinity"]
healthcheck:
disable: true
volumes:
- ./scripts:/app/scripts:ro
- ./secrets/certs:/certs:ro
- ./secrets/bao_runtime:/bao:ro
networks: [edge, app, data, telemetry]
read_only: true
tmpfs: [/tmp]
security_opt: ["no-new-privileges:true"]
cap_drop: [ALL]
profiles: ["tools"]
deploy:
replicas: 1
resources:
limits:
cpus: "0.25"
memory: 128M
secrets:
postgres_password: {file: ./secrets/postgres_password}
db_api_password: {file: ./secrets/db_api_password}
db_worker_password: {file: ./secrets/db_worker_password}
db_relay_password: {file: ./secrets/db_relay_password}
migrate_database_url: {file: ./secrets/migrate_database_url}
rabbitmq_root_user: {file: ./secrets/rabbitmq_root_user}
rabbitmq_root_password: {file: ./secrets/rabbitmq_root_password}
minio_root_user: {file: ./secrets/minio_root_user}
minio_root_password: {file: ./secrets/minio_root_password}
s3_api_access_key: {file: ./secrets/s3_api_access_key}
s3_api_secret_key: {file: ./secrets/s3_api_secret_key}
s3_worker_access_key: {file: ./secrets/s3_worker_access_key}
s3_worker_secret_key: {file: ./secrets/s3_worker_secret_key}
grafana_admin_password: {file: ./secrets/grafana_admin_password}
volumes:
pgdata:
miniodata:
rabbitmqdata:
openbaodata:
promdata:
lokidata:
tempodata:
grafanadata:
networks:
edge:
name: lab7_edge
driver: bridge
app:
name: lab7_app
driver: bridge
internal: true
data:
name: lab7_data
driver: bridge
internal: true
broker:
name: lab7_broker
driver: bridge
internal: true
otelnet:
name: lab7_otelnet
driver: bridge
internal: true
admin:
name: lab7_admin
driver: bridge
telemetry:
name: lab7_telemetry
driver: bridge
internal: true
promnet:
name: lab7_promnet
driver: bridge
internal: true
lokinet:
name: lab7_lokinet
driver: bridge
internal: true
temponet:
name: lab7_temponet
driver: bridge
internal: true
collectorscrape:
name: lab7_collectorscrape
driver: bridge
internal: true