Files
mtusi2026lab7/compose.yaml
T
gamayunov2004 9fb7dde29b
Skeleton contracts / contracts (pull_request) Canceled after 0s
ЛР 7: TLS, mTLS, OpenBao и безопасность — на 3
2026-11-22 06:03:17 +03:00

222 lines
8.4 KiB
YAML

name: mtusi-lab7-grade3
x-app: &app
image: mtusi-lab7-api:grade3
build: .
cap_drop: [ALL]
security_opt: ["no-new-privileges:true"]
cpus: 1.0
mem_limit: 384m
pids_limit: 64
init: true
restart: unless-stopped
stop_grace_period: 5s
x-environment: &environment
BAO_ADDR: https://openbao:8200
S3_ENDPOINT: https://s3:9000
S3_BUCKET: messenger-attachments
S3_REGION: us-east-1
OTEL_EXPORTER_OTLP_ENDPOINT: https://otel-collector:4318
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
services:
openbao:
image: quay.io/openbao/openbao:2.4.4
command: [server, -config=/run/config/server.hcl]
environment: {SKIP_SETCAP: "true"}
ports: ["127.0.0.1:8200:8200"]
volumes: ["./secrets/pki/openbao:/run/tls:ro","./infra/openbao/server.hcl:/run/config/server.hcl:ro","bao_data:/openbao/file"]
restart: unless-stopped
postgres:
image: postgres:16.8-bookworm
entrypoint: [sh, /run/config/start.sh]
environment:
POSTGRES_USER: postgres
POSTGRES_DB: messenger
POSTGRES_PASSWORD_FILE: /run/private/pg_admin
volumes: ["./secrets/pki/postgres:/run/tls:ro","./secrets/ca:/run/ca:ro","./infra/postgres:/run/config:ro","./infra/postgres/init.sh:/docker-entrypoint-initdb.d/10-roles.sh:ro","./secrets/postgres:/run/private:ro","postgres_data:/var/lib/postgresql/data"]
healthcheck:
test: [CMD-SHELL, "PGSSLMODE=verify-full PGSSLROOTCERT=/run/ca/server.crt pg_isready -h postgres -U lab_migrate -d messenger"]
interval: 2s
retries: 30
restart: unless-stopped
migrate:
<<: *app
command: [python, -m, src.db]
restart: "no"
environment: {DATABASE_URL_FILE: /run/private/pg_url}
volumes: ["./secrets/ca:/run/ca:ro","./secrets/postgres/pg_url:/run/private/pg_url:ro"]
depends_on:
postgres: {condition: service_healthy}
s3:
image: rustfs/rustfs:1.0.0-alpha.85@sha256:23ff2af1ec2d64e0fb9608a1c39b5eb96fcff3a8efecf332986c948b0e3e4f8a
entrypoint: [sh, -ec, "unset RUSTFS_ACCESS_KEY RUSTFS_SECRET_KEY; exec /entrypoint.sh rustfs"]
environment:
RUSTFS_VOLUMES: /data
RUSTFS_ADDRESS: ":9000"
RUSTFS_CONSOLE_ENABLE: "false"
RUSTFS_TLS_PATH: /run/tls
RUSTFS_ACCESS_KEY_FILE: /run/private/access
RUSTFS_SECRET_KEY_FILE: /run/private/password
volumes: ["./secrets/pki/s3:/run/tls:ro","./secrets/ca:/run/ca:ro","./secrets/s3-admin:/run/private:ro","s3_data:/data"]
healthcheck:
test: [CMD, curl, --cacert, /run/ca/server.crt, --resolve, "s3:9000:127.0.0.1", -fsS, --max-time, "2", "https://s3:9000/health"]
interval: 3s
retries: 30
restart: unless-stopped
broker:
image: rabbitmq:4.1.4-alpine
hostname: broker
volumes: ["./secrets/pki/broker:/run/tls:ro","./secrets/ca:/run/ca:ro","./infra/rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro","./secrets/generated/definitions.json:/run/config/definitions.json:ro","broker_data:/var/lib/rabbitmq"]
healthcheck:
test: [CMD, nc, -z, -w, "2", "127.0.0.1", "5671"]
interval: 3s
start_period: 30s
retries: 20
restart: unless-stopped
api1:
<<: *app
environment: {<<: *environment, BAO_ROLE: api, INSTANCE_ID: api1}
volumes: ["./secrets/pki/api1:/run/tls:ro","./secrets/ca:/run/ca:ro","./secrets/pki/bao-api:/run/identity:ro"]
depends_on:
migrate: {condition: service_completed_successfully}
s3: {condition: service_healthy}
broker: {condition: service_healthy}
api2:
<<: *app
environment: {<<: *environment, BAO_ROLE: api, INSTANCE_ID: api2}
volumes: ["./secrets/pki/api2:/run/tls:ro","./secrets/ca:/run/ca:ro","./secrets/pki/bao-api:/run/identity:ro"]
depends_on:
migrate: {condition: service_completed_successfully}
s3: {condition: service_healthy}
broker: {condition: service_healthy}
worker:
<<: *app
command: [python, -m, src.worker]
environment: {<<: *environment, BAO_ROLE: worker, INSTANCE_ID: worker}
volumes: ["./secrets/ca:/run/ca:ro","./secrets/pki/bao-worker:/run/identity:ro"]
depends_on:
migrate: {condition: service_completed_successfully}
s3: {condition: service_healthy}
broker: {condition: service_healthy}
lb:
image: haproxy:3.0.11-alpine
ports: ["127.0.0.1:8443:8443"]
volumes: ["./secrets/pki/lb:/run/tls:ro","./secrets/ca:/run/ca:ro","./secrets/pki/lb-client:/run/identity:ro","./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro"]
restart: unless-stopped
otel-collector:
image: haproxy:3.0.11-alpine
volumes: ["./secrets/pki/otel-collector:/run/tls:ro","./secrets/generated/otel-collector.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro"]
restart: unless-stopped
collector-local:
image: otel/opentelemetry-collector-contrib:0.127.0
network_mode: service:otel-collector
command: ["--config=/run/config/collector.json"]
volumes: ["./secrets/ca:/run/ca:ro","./secrets/generated/collector.json:/run/config/collector.json:ro"]
environment: {"GOMEMLIMIT":"144MiB"}
mem_limit: 192m
restart: unless-stopped
prometheus:
image: haproxy:3.0.11-alpine
volumes: ["./secrets/pki/prometheus:/run/tls:ro","./secrets/generated/prometheus.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro"]
restart: unless-stopped
prometheus-local:
image: prom/prometheus:v3.4.1
network_mode: service:prometheus
command: ["--config.file=/etc/prometheus/prometheus.yml","--web.listen-address=127.0.0.1:19090","--web.enable-remote-write-receiver","--storage.tsdb.path=/prometheus","--storage.tsdb.retention.time=2d","--storage.tsdb.retention.size=256MB"]
volumes: ["./infra/otel/prometheus.yaml:/etc/prometheus/prometheus.yml:ro","prometheus_data:/prometheus"]
mem_limit: 384m
restart: unless-stopped
loki:
image: haproxy:3.0.11-alpine
volumes: ["./secrets/pki/loki:/run/tls:ro","./secrets/generated/loki.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro"]
restart: unless-stopped
loki-local:
image: grafana/loki:3.5.1
network_mode: service:loki
command: ["-config.file=/etc/loki/local-config.yaml"]
volumes: ["./infra/otel/loki.yaml:/etc/loki/local-config.yaml:ro","loki_data:/loki"]
environment: {"GOMEMLIMIT":"320MiB","GOMAXPROCS":"2"}
mem_limit: 448m
restart: unless-stopped
tempo:
image: haproxy:3.0.11-alpine
volumes: ["./secrets/pki/tempo:/run/tls:ro","./secrets/generated/tempo.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro"]
restart: unless-stopped
tempo-local:
image: grafana/tempo:2.8.0
network_mode: service:tempo
command: ["-config.file=/etc/tempo.yaml"]
volumes: ["./infra/otel/tempo.yaml:/etc/tempo.yaml:ro","tempo_data:/var/tempo"]
environment: {"GOMEMLIMIT":"320MiB","GOMAXPROCS":"2"}
mem_limit: 448m
restart: unless-stopped
grafana:
image: grafana/grafana:12.0.2
ports: ["127.0.0.1:3443:3000"]
environment:
GF_SERVER_PROTOCOL: https
GF_SERVER_CERT_FILE: /run/tls/server.crt
GF_SERVER_CERT_KEY: /run/tls/server.key
GF_SERVER_ROOT_URL: https://localhost:3443/
GF_PLUGINS_PREINSTALL_DISABLED: "true"
GF_SECURITY_ADMIN_PASSWORD__FILE: /run/private/password
GF_SECURITY_COOKIE_SECURE: "true"
GF_USERS_ALLOW_SIGN_UP: "false"
GF_ANALYTICS_REPORTING_ENABLED: "false"
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
GF_ANALYTICS_CHECK_FOR_PLUGIN_UPDATES: "false"
volumes: ["./secrets/pki/grafana:/run/tls:ro","./secrets/grafana/password:/run/private/password:ro","./secrets/generated/datasources.json:/etc/grafana/provisioning/datasources/lab7.yaml:ro","./infra/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro","./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro","grafana_data:/var/lib/grafana"]
mem_limit: 384m
restart: unless-stopped
s3-bootstrap:
profiles: [setup]
image: mtusi-lab7-s3-bootstrap:grade3
build: {context: ., dockerfile: infra/Dockerfile.s3-bootstrap}
volumes:
- ./secrets/ca:/run/ca:ro
- ./secrets/s3-admin:/run/admin:ro
- ./secrets/s3:/run/scoped:ro
tmpfs: [/tmp]
depends_on:
s3: {condition: service_healthy}
tools:
profiles: [test]
image: mtusi-lab7-tools:grade3
build: {context: ., dockerfile: infra/Dockerfile.tools}
volumes: ["./secrets/ca:/run/ca:ro"]
environment:
BASE_URL: https://localhost:8443
CA_FILE: /run/ca/public.crt
network_mode: service:lb
volumes:
bao_data:
postgres_data:
broker_data:
s3_data:
prometheus_data:
loki_data:
tempo_data:
grafana_data: