forked from mtusi2026/mtusi2026lab7
353 lines
9.7 KiB
YAML
353 lines
9.7 KiB
YAML
name: mtusi2026lab7
|
|
|
|
x-hardening: &hardening
|
|
read_only: true
|
|
cap_drop: [ALL]
|
|
security_opt: [no-new-privileges:true]
|
|
tmpfs:
|
|
- /tmp:size=24m,noexec,nosuid,nodev,mode=1777
|
|
pids_limit: 96
|
|
cpus: 0.5
|
|
mem_limit: 256m
|
|
logging:
|
|
driver: json-file
|
|
options: {max-size: 5m, max-file: "2"}
|
|
|
|
x-app: &app
|
|
<<: *hardening
|
|
image: mtusi2026lab7-app:1
|
|
build: .
|
|
restart: on-failure
|
|
|
|
x-app-env: &app-env
|
|
S3_ENDPOINT: https://s3:9000
|
|
S3_BUCKET: messenger-attachments
|
|
S3_REGION: us-east-1
|
|
BAO_ADDR: https://openbao:8200
|
|
OTEL_EXPORTER_OTLP_ENDPOINT: https://collector:4318
|
|
OTEL_EXPORTER_OTLP_CERTIFICATE: /pki/ca.crt
|
|
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE: /pki/service.crt
|
|
OTEL_EXPORTER_OTLP_CLIENT_KEY: /pki/service.key
|
|
JOB_TIMEOUT_SECONDS: "30"
|
|
JOB_LEASE_SECONDS: "15"
|
|
JOB_MAX_ATTEMPTS: "5"
|
|
|
|
x-gateway: &gateway
|
|
<<: *hardening
|
|
image: haproxy:3.0.11-bookworm
|
|
user: "99:99"
|
|
mem_limit: 96m
|
|
|
|
services:
|
|
volume-permissions:
|
|
<<: *app
|
|
profiles: [setup]
|
|
restart: "no"
|
|
user: "0:0"
|
|
cap_add: [CHOWN]
|
|
command: [sh, -ec, "chown 10001:10001 /vol/s3 /vol/otel /vol/tempo /vol/loki; chown 100:1000 /vol/bao"]
|
|
volumes:
|
|
- s3_data:/vol/s3
|
|
- collector_data:/vol/otel
|
|
- tempo_data:/vol/tempo
|
|
- loki_data:/vol/loki
|
|
- bao_raft_active:/vol/bao
|
|
|
|
db:
|
|
<<: *hardening
|
|
image: postgres:16.9-bookworm
|
|
cap_add: [CHOWN, DAC_OVERRIDE, FOWNER, SETUID, SETGID]
|
|
entrypoint: [/bin/sh, /infra/db-entrypoint.sh]
|
|
tmpfs:
|
|
- /var/run/postgresql:size=8m,nosuid,nodev
|
|
- /run/pg-tls:size=1m,nosuid,nodev
|
|
- /tmp:size=16m,nosuid,nodev
|
|
cpus: 1
|
|
mem_limit: 512m
|
|
environment:
|
|
POSTGRES_DB: messenger
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD_FILE: /credentials/db_owner
|
|
POSTGRES_INITDB_ARGS: --auth-host=scram-sha-256 --auth-local=peer
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
- ./secrets/bootstrap/db:/credentials:ro
|
|
- ./secrets/runtime/db:/pki:ro
|
|
- ./infra/db-entrypoint.sh:/infra/db-entrypoint.sh:ro
|
|
- ./infra/pg_hba.conf:/etc/lab-pg-hba.conf:ro
|
|
- ./infra/pg-init.sh:/docker-entrypoint-initdb.d/10-roles.sh:ro
|
|
healthcheck:
|
|
test: [CMD, pg_isready, -h, db, -U, postgres, -d, messenger]
|
|
interval: 2s
|
|
timeout: 3s
|
|
retries: 30
|
|
|
|
audit:
|
|
<<: *app
|
|
networks: [default, vault]
|
|
profiles: [audit]
|
|
restart: "no"
|
|
command: [python, /app/student-tests/trust.py]
|
|
volumes:
|
|
- ./secrets/runtime:/audit/runtime:ro
|
|
- ./secrets/foreign/client:/audit/foreign/client:ro
|
|
- ./secrets/rotation/probe:/audit/rotation:ro
|
|
- ./student-tests:/app/student-tests:ro
|
|
- ./secrets/runtime/api/ca.crt:/pki/ca.crt:ro
|
|
|
|
migrate:
|
|
<<: *app
|
|
restart: "no"
|
|
command: [python, -m, src.launch, migrate]
|
|
volumes:
|
|
- ./secrets/runtime/db/ca.crt:/pki/ca.crt:ro
|
|
- ./secrets/bootstrap/db/db_owner:/credentials/db_owner:ro
|
|
|
|
s3:
|
|
<<: *hardening
|
|
image: cgr.dev/chainguard/minio@sha256:616286de6ef3a1892876b126e745e152d8e03add6357203f8a1f854bdd1dce76
|
|
user: "10001:10001"
|
|
command: [server, /data, --address, ":9000", --console-address, "127.0.0.1:9001", --certs-dir, /pki]
|
|
cpus: 1
|
|
mem_limit: 512m
|
|
environment:
|
|
HOME: /tmp
|
|
MINIO_BROWSER: "off"
|
|
MINIO_ROOT_USER: operator
|
|
MINIO_ROOT_PASSWORD_FILE: /credentials/root
|
|
volumes:
|
|
- s3_data:/data
|
|
- ./secrets/runtime/s3:/pki:ro
|
|
- ./secrets/bootstrap/s3/root:/credentials/root:ro
|
|
|
|
s3-bootstrap:
|
|
<<: *hardening
|
|
image: mtusi2026lab7-mc:2025-04-16
|
|
build:
|
|
context: .
|
|
dockerfile: infra/s3.Dockerfile
|
|
args:
|
|
COMPONENT: mc
|
|
RELEASE: RELEASE.2025-04-16T18-13-26Z
|
|
SHA256: ac90da87a35641be5a0ac75d49de5161ddb47d629b5ba01261b0ae9e00aea15f
|
|
user: "10001:10001"
|
|
entrypoint: [/bin/sh, /bootstrap.sh]
|
|
volumes:
|
|
- ./scripts/bootstrap_s3.sh:/bootstrap.sh:ro
|
|
- ./infra/s3:/policies:ro
|
|
- ./secrets/bootstrap/s3:/credentials:ro
|
|
- ./secrets/runtime/s3/ca.crt:/pki/ca.crt:ro
|
|
|
|
openbao:
|
|
<<: *hardening
|
|
networks: [vault]
|
|
image: openbao/openbao:2.7.2
|
|
user: "100:1000"
|
|
entrypoint: [bao]
|
|
command: [server, -config=/etc/lab-bao.hcl]
|
|
ports: ["127.0.0.1:8207:8200"]
|
|
volumes:
|
|
- bao_raft_active:/openbao/file
|
|
- bao_logs:/openbao/logs
|
|
- ./infra/openbao/server.hcl:/etc/lab-bao.hcl:ro
|
|
- ./secrets/runtime/openbao:/pki:ro
|
|
|
|
lb:
|
|
<<: *gateway
|
|
ports: ["127.0.0.1:8443:8443"]
|
|
volumes:
|
|
- ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
|
- ./secrets/runtime/lb:/pki:ro
|
|
|
|
api:
|
|
<<: *app
|
|
networks: [default, vault]
|
|
tmpfs:
|
|
- /tmp:size=48m,noexec,nosuid,nodev,mode=1777
|
|
scale: 2
|
|
cpus: 1
|
|
mem_limit: 512m
|
|
environment:
|
|
<<: *app-env
|
|
BAO_ROLE: api
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
OTEL_SERVICE_NAME: messenger-api
|
|
volumes:
|
|
- ./secrets/runtime/api:/pki:ro
|
|
healthcheck:
|
|
test: [CMD, python, /app/scripts/api_health.py]
|
|
interval: 4s
|
|
timeout: 3s
|
|
retries: 18
|
|
|
|
broker:
|
|
<<: *gateway
|
|
volumes:
|
|
- ./infra/tls/broker.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
|
- ./secrets/runtime/broker:/pki:ro
|
|
|
|
streams:
|
|
<<: *hardening
|
|
image: redis:7.4.3-bookworm
|
|
network_mode: service:broker
|
|
depends_on: [broker]
|
|
user: "999:999"
|
|
command: [redis-server, /etc/lab-redis.conf]
|
|
volumes:
|
|
- broker_data:/data
|
|
- ./secrets/runtime/broker/users.acl:/credentials/users.acl:ro
|
|
- ./infra/redis.conf:/etc/lab-redis.conf:ro
|
|
|
|
worker:
|
|
<<: *app
|
|
networks: [default, vault]
|
|
tmpfs:
|
|
- /tmp:size=48m,noexec,nosuid,nodev,mode=1777
|
|
cpus: 1
|
|
mem_limit: 768m
|
|
command: [python, -m, src.launch, worker]
|
|
environment:
|
|
<<: *app-env
|
|
BAO_ROLE: worker
|
|
OTEL_SERVICE_NAME: messenger-worker
|
|
WORKER_CONCURRENCY: "1"
|
|
WORKER_IMAGE_MEMORY_MIB: "512"
|
|
volumes:
|
|
- ./secrets/runtime/worker:/pki:ro
|
|
|
|
dispatcher:
|
|
<<: *app
|
|
networks: [default, vault]
|
|
command: [python, -m, src.launch, dispatcher]
|
|
environment:
|
|
<<: *app-env
|
|
BAO_ROLE: dispatcher
|
|
OTEL_SERVICE_NAME: messenger-dispatcher
|
|
volumes:
|
|
- ./secrets/runtime/dispatcher:/pki:ro
|
|
|
|
reconciler:
|
|
<<: *app
|
|
networks: [default, vault]
|
|
command: [python, -m, src.launch, cleanup, --apply, --loop]
|
|
environment:
|
|
<<: *app-env
|
|
BAO_ROLE: reconciler
|
|
OTEL_SERVICE_NAME: messenger-reconciler
|
|
volumes:
|
|
- ./secrets/runtime/reconciler:/pki:ro
|
|
|
|
collector:
|
|
<<: *gateway
|
|
volumes:
|
|
- ./infra/tls/collector.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
|
- ./secrets/runtime/collector:/pki:ro
|
|
|
|
otel:
|
|
<<: *hardening
|
|
image: otel/opentelemetry-collector-contrib:0.123.0
|
|
network_mode: service:collector
|
|
depends_on: [collector]
|
|
user: "10001:10001"
|
|
command: [--config=/etc/otel/config.yaml]
|
|
volumes:
|
|
- ./infra/otel/collector.yaml:/etc/otel/config.yaml:ro
|
|
- ./secrets/runtime/collector:/pki:ro
|
|
- collector_data:/var/lib/otel
|
|
|
|
prometheus:
|
|
<<: *gateway
|
|
volumes:
|
|
- ./infra/tls/prometheus.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
|
- ./secrets/runtime/prometheus:/pki:ro
|
|
|
|
metrics:
|
|
<<: *hardening
|
|
image: prom/prometheus:v3.2.1
|
|
network_mode: service:prometheus
|
|
depends_on: [prometheus]
|
|
command:
|
|
- --config.file=/etc/prometheus/prometheus.yaml
|
|
- --storage.tsdb.path=/prometheus
|
|
- --storage.tsdb.retention.time=2d
|
|
- --web.listen-address=127.0.0.1:19090
|
|
volumes:
|
|
- ./infra/otel/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro
|
|
- ./infra/otel/alerts.yaml:/etc/prometheus/alerts.yaml:ro
|
|
- ./infra/otel/recording.yaml:/etc/prometheus/recording.yaml:ro
|
|
- ./secrets/runtime/scraper:/pki:ro
|
|
- prometheus_data:/prometheus
|
|
|
|
loki:
|
|
<<: *gateway
|
|
volumes:
|
|
- ./infra/tls/loki.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
|
- ./secrets/runtime/loki:/pki:ro
|
|
|
|
logs:
|
|
<<: *hardening
|
|
image: grafana/loki:3.4.2
|
|
network_mode: service:loki
|
|
depends_on: [loki]
|
|
mem_limit: 384m
|
|
command: [-config.file=/etc/loki/config.yaml]
|
|
volumes:
|
|
- ./infra/otel/loki.yaml:/etc/loki/config.yaml:ro
|
|
- loki_data:/loki
|
|
|
|
tempo:
|
|
<<: *gateway
|
|
volumes:
|
|
- ./infra/tls/tempo.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
|
- ./secrets/runtime/tempo:/pki:ro
|
|
|
|
traces:
|
|
<<: *hardening
|
|
image: grafana/tempo:2.7.2
|
|
network_mode: service:tempo
|
|
depends_on: [tempo]
|
|
user: "10001:10001"
|
|
cpus: 1
|
|
mem_limit: 512m
|
|
command: [-config.file=/etc/tempo/config.yaml]
|
|
volumes:
|
|
- ./infra/otel/tempo.yaml:/etc/tempo/config.yaml:ro
|
|
- tempo_data:/var/tempo
|
|
|
|
grafana:
|
|
<<: *hardening
|
|
image: grafana/grafana:11.6.0-ubuntu
|
|
ports: ["127.0.0.1:3007:3000"]
|
|
mem_limit: 512m
|
|
environment:
|
|
GF_SERVER_PROTOCOL: https
|
|
GF_SERVER_CERT_FILE: /pki/service.crt
|
|
GF_SERVER_CERT_KEY: /pki/service.key
|
|
GF_SECURITY_ADMIN_PASSWORD__FILE: /credentials/admin
|
|
GF_USERS_ALLOW_SIGN_UP: "false"
|
|
GF_AUTH_ANONYMOUS_ENABLED: "false"
|
|
GF_ANALYTICS_REPORTING_ENABLED: "false"
|
|
GF_PLUGINS_PREINSTALL_DISABLED: "true"
|
|
volumes:
|
|
- grafana_data:/var/lib/grafana
|
|
- ./secrets/runtime/grafana:/pki:ro
|
|
- ./secrets/bootstrap/grafana/admin:/credentials/admin:ro
|
|
- ./secrets/runtime/grafana/sources.yaml:/etc/grafana/provisioning/datasources/lab7.yaml:ro
|
|
- ./infra/otel/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
|
|
- ./infra/otel/grafana/dashboards:/var/lib/grafana/dashboards:ro
|
|
|
|
volumes:
|
|
postgres_data:
|
|
s3_data:
|
|
bao_raft_active:
|
|
bao_logs:
|
|
broker_data:
|
|
collector_data:
|
|
prometheus_data:
|
|
loki_data:
|
|
tempo_data:
|
|
grafana_data:
|
|
|
|
networks:
|
|
vault:
|