Files
mtusi2026lab7/compose.yaml
T
2026-11-27 21:55:47 +03:00

686 lines
17 KiB
YAML

name: mtusi2026lab7
services:
api1:
image: mtusi2026lab7-api:local
networks:
- backend
cpus: 1.0
mem_limit: 384m
read_only: true
cap_drop: &drop_all_capabilities
- ALL
security_opt: &no_new_privileges
- no-new-privileges:true
tmpfs: &runtime_tmpfs
- /tmp:rw,noexec,nosuid,size=64m
restart: unless-stopped
build: .
pull_policy: never
user: 1000:1000
entrypoint:
- python
- -m
- src.secure_run
command:
- python
- -m
- src
environment:
SERVICE_ROLE: api
APP_HOST: 127.0.0.1
APP_PORT: '8080'
OTEL_SERVICE_NAME: messenger-api
OTEL_EXPORTER_OTLP_ENDPOINT: https://otel-collector:44318
OTEL_EXPORTER_OTLP_CERTIFICATE: /run/identity/ca.crt
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE: /run/identity/tls.crt
OTEL_EXPORTER_OTLP_CLIENT_KEY: /run/identity/tls.key
WORKER_CONCURRENCY: '2'
JOB_MEMORY_MB: '768'
JOB_TIMEOUT_SECONDS: '60'
volumes:
- ./secrets/api:/run/identity:ro
init: true
healthcheck:
disable: true
pids_limit: 64
stop_grace_period: 15s
api1-tls:
image: haproxy:3.0.12-alpine
cpus: 0.25
mem_limit: 64m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 65532:65532
volumes:
- ./secrets/api1:/run/identity:ro
- ./infra/tls/api1.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
network_mode: service:api1
depends_on:
- api1
api2:
image: mtusi2026lab7-api:local
networks:
- backend
cpus: 1.0
mem_limit: 384m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
build: .
pull_policy: never
user: 1000:1000
entrypoint:
- python
- -m
- src.secure_run
command:
- python
- -m
- src
environment:
SERVICE_ROLE: api
APP_HOST: 127.0.0.1
APP_PORT: '8080'
OTEL_SERVICE_NAME: messenger-api
OTEL_EXPORTER_OTLP_ENDPOINT: https://otel-collector:44318
OTEL_EXPORTER_OTLP_CERTIFICATE: /run/identity/ca.crt
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE: /run/identity/tls.crt
OTEL_EXPORTER_OTLP_CLIENT_KEY: /run/identity/tls.key
WORKER_CONCURRENCY: '2'
JOB_MEMORY_MB: '768'
JOB_TIMEOUT_SECONDS: '60'
volumes:
- ./secrets/api:/run/identity:ro
init: true
healthcheck:
disable: true
pids_limit: 64
stop_grace_period: 15s
api2-tls:
image: haproxy:3.0.12-alpine
cpus: 0.25
mem_limit: 64m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 65532:65532
volumes:
- ./secrets/api2:/run/identity:ro
- ./infra/tls/api2.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
network_mode: service:api2
depends_on:
- api2
worker:
image: mtusi2026lab7-api:local
networks:
- backend
cpus: 2.0
mem_limit: 2g
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
build: .
pull_policy: never
user: 1000:1000
entrypoint:
- python
- -m
- src.secure_run
command:
- python
- -m
- src.worker
environment:
SERVICE_ROLE: worker
APP_HOST: 127.0.0.1
APP_PORT: '8080'
OTEL_SERVICE_NAME: messenger-worker
OTEL_EXPORTER_OTLP_ENDPOINT: https://otel-collector:44318
OTEL_EXPORTER_OTLP_CERTIFICATE: /run/identity/ca.crt
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE: /run/identity/tls.crt
OTEL_EXPORTER_OTLP_CLIENT_KEY: /run/identity/tls.key
WORKER_CONCURRENCY: '2'
JOB_MEMORY_MB: '768'
JOB_TIMEOUT_SECONDS: '60'
volumes:
- ./secrets/worker:/run/identity:ro
init: true
healthcheck:
disable: true
pids_limit: 64
stop_grace_period: 15s
dispatcher:
image: mtusi2026lab7-api:local
networks:
- backend
cpus: 1.0
mem_limit: 384m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
build: .
pull_policy: never
user: 1000:1000
entrypoint:
- python
- -m
- src.secure_run
command:
- python
- -m
- src.jobs
- dispatch
environment:
SERVICE_ROLE: dispatcher
APP_HOST: 127.0.0.1
APP_PORT: '8080'
OTEL_SERVICE_NAME: messenger-dispatcher
OTEL_EXPORTER_OTLP_ENDPOINT: https://otel-collector:44318
OTEL_EXPORTER_OTLP_CERTIFICATE: /run/identity/ca.crt
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE: /run/identity/tls.crt
OTEL_EXPORTER_OTLP_CLIENT_KEY: /run/identity/tls.key
WORKER_CONCURRENCY: '2'
JOB_MEMORY_MB: '768'
JOB_TIMEOUT_SECONDS: '60'
volumes:
- ./secrets/dispatcher:/run/identity:ro
init: true
healthcheck:
disable: true
pids_limit: 64
stop_grace_period: 15s
cleanup:
image: mtusi2026lab7-api:local
networks:
- backend
cpus: 1.0
mem_limit: 384m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
build: .
pull_policy: never
user: 1000:1000
entrypoint:
- python
- -m
- src.secure_run
command:
- python
- -m
- src.cleanup
environment:
SERVICE_ROLE: cleanup
APP_HOST: 127.0.0.1
APP_PORT: '8080'
OTEL_SERVICE_NAME: messenger-cleanup
OTEL_EXPORTER_OTLP_ENDPOINT: https://otel-collector:44318
OTEL_EXPORTER_OTLP_CERTIFICATE: /run/identity/ca.crt
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE: /run/identity/tls.crt
OTEL_EXPORTER_OTLP_CLIENT_KEY: /run/identity/tls.key
WORKER_CONCURRENCY: '2'
JOB_MEMORY_MB: '768'
JOB_TIMEOUT_SECONDS: '60'
OTEL_SDK_DISABLED: 'true'
volumes:
- ./secrets/cleanup:/run/identity:ro
init: true
healthcheck:
disable: true
pids_limit: 64
stop_grace_period: 15s
lb:
image: haproxy:3.0.12-alpine
networks:
- edge
- backend
cpus: 0.5
mem_limit: 96m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 65532:65532
ports:
- 127.0.0.1:8443:8443
volumes:
- ./secrets/lb:/run/identity:ro
- ./infra/tls/lb.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
postgres:
image: postgres:17.4-bookworm
networks:
- backend
cpus: 1.0
mem_limit: 512m
read_only: true
cap_drop:
- ALL
security_opt: *no_new_privileges
tmpfs:
- /tmp:rw,nosuid,size=16m
- /var/run/postgresql:rw,nosuid,size=16m
restart: unless-stopped
cap_add:
- CHOWN
- DAC_OVERRIDE
- FOWNER
- SETGID
- SETUID
environment:
POSTGRES_DB: messenger
POSTGRES_PASSWORD_FILE: /run/admin/postgres-password
volumes:
- type: volume
source: postgres_data
target: /var/lib/postgresql/data
volume:
nocopy: true
- ./secrets/postgres:/run/identity:ro
- ./secrets/postgres-admin:/run/admin:ro
- ./infra/postgres/pg_hba.conf:/etc/pg_hba.conf:ro
- ./infra/postgres/start.sh:/start.sh:ro
entrypoint:
- sh
- /start.sh
redis:
image: redis:7.4.2-bookworm
networks:
- backend
cpus: 0.5
mem_limit: 256m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 999:999
command:
- redis-server
- /run/config/redis.conf
volumes:
- type: volume
source: redis_data
target: /data
volume:
nocopy: true
- ./secrets/redis-config:/run/config:ro
redis-tls:
image: haproxy:3.0.12-alpine
cpus: 0.25
mem_limit: 64m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 65532:65532
volumes:
- ./secrets/redis:/run/identity:ro
- ./infra/tls/redis.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
network_mode: service:redis
depends_on:
- redis
broker:
image: redis:7.4.2-bookworm
networks:
- backend
cpus: 0.5
mem_limit: 256m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 999:999
command:
- redis-server
- /run/config/redis.conf
volumes:
- type: volume
source: broker_data
target: /data
volume:
nocopy: true
- ./secrets/broker-config:/run/config:ro
broker-tls:
image: haproxy:3.0.12-alpine
cpus: 0.25
mem_limit: 64m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 65532:65532
volumes:
- ./secrets/broker:/run/identity:ro
- ./infra/tls/broker.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
network_mode: service:broker
depends_on:
- broker
s3:
image: minio/minio@sha256:14cea493d9a34af32f524e538b8346cf79f3321eff8e708c1e2960462bd8936e
networks:
- backend
cpus: 1.0
mem_limit: 512m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 1000:1000
entrypoint:
- sh
- -c
command:
- export MINIO_ROOT_USER=$$(cat /run/admin/user); export MINIO_ROOT_PASSWORD=$$(cat
/run/admin/password); exec minio server /data --address 127.0.0.1:9000 --console-address
127.0.0.1:9001
environment:
MINIO_BROWSER: 'off'
volumes:
- type: volume
source: s3_data
target: /data
volume:
nocopy: true
- ./secrets/s3-admin:/run/admin:ro
s3-tls:
image: haproxy:3.0.12-alpine
cpus: 0.25
mem_limit: 64m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 65532:65532
volumes:
- ./secrets/s3:/run/identity:ro
- ./infra/tls/s3.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
network_mode: service:s3
depends_on:
- s3
openbao:
image: openbao/openbao:2.4.4
networks:
- edge
- backend
cpus: 0.5
mem_limit: 256m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 100:1000
entrypoint:
- bao
command:
- server
- -config=/etc/bao/config.hcl
volumes:
- type: volume
source: bao_data
target: /bao/data
volume:
nocopy: true
- ./secrets/openbao:/run/identity:ro
- ./infra/openbao/config.hcl:/etc/bao/config.hcl:ro
ports:
- 127.0.0.1:8200:8200
otel-collector:
image: otel/opentelemetry-collector-contrib:0.136.0
networks:
- backend
cpus: 0.5
mem_limit: 256m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 1000:1000
command:
- --config=/etc/otel/config.yaml
volumes:
- ./secrets/otel-collector:/run/identity:ro
- ./infra/otel/collector.yaml:/etc/otel/config.yaml:ro
otel-collector-tls:
image: haproxy:3.0.12-alpine
cpus: 0.25
mem_limit: 64m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 65532:65532
volumes:
- ./secrets/otel-collector:/run/identity:ro
- ./infra/tls/otel-collector.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
network_mode: service:otel-collector
depends_on:
- otel-collector
prometheus:
image: prom/prometheus:v3.6.0
networks:
- backend
cpus: 0.5
mem_limit: 384m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 65534:65534
command:
- --config.file=/etc/prometheus/prometheus.yaml
- --storage.tsdb.retention.time=3d
- --web.listen-address=127.0.0.1:9090
volumes:
- type: volume
source: prometheus_data
target: /prometheus
volume:
nocopy: true
- ./secrets/prometheus:/run/identity:ro
- ./infra/otel/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro
- ./infra/otel/alerts.yaml:/etc/prometheus/alerts.yaml:ro
prometheus-tls:
image: haproxy:3.0.12-alpine
cpus: 0.25
mem_limit: 64m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 65532:65532
volumes:
- ./secrets/prometheus:/run/identity:ro
- ./infra/tls/prometheus.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
network_mode: service:prometheus
depends_on:
- prometheus
loki:
image: grafana/loki:3.5.7
networks:
- backend
cpus: 0.5
mem_limit: 384m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 1000:1000
command:
- -config.file=/etc/config.yaml
volumes:
- type: volume
source: loki_data
target: /loki
volume:
nocopy: true
- ./infra/otel/loki.yaml:/etc/config.yaml:ro
loki-tls:
image: haproxy:3.0.12-alpine
cpus: 0.25
mem_limit: 64m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 65532:65532
volumes:
- ./secrets/loki:/run/identity:ro
- ./infra/tls/loki.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
network_mode: service:loki
depends_on:
- loki
tempo:
image: grafana/tempo:2.9.0
networks:
- backend
cpus: 0.5
mem_limit: 384m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 1000:1000
command:
- -config.file=/etc/config.yaml
volumes:
- type: volume
source: tempo_data
target: /var/tempo
volume:
nocopy: true
- ./infra/otel/tempo.yaml:/etc/config.yaml:ro
tempo-tls:
image: haproxy:3.0.12-alpine
cpus: 0.25
mem_limit: 64m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 65532:65532
volumes:
- ./secrets/tempo:/run/identity:ro
- ./infra/tls/tempo.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
network_mode: service:tempo
depends_on:
- tempo
grafana:
image: grafana/grafana:12.2.0
networks:
- edge
- backend
cpus: 0.5
mem_limit: 384m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 472:472
environment:
GF_SERVER_HTTP_ADDR: 127.0.0.1
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD__FILE: /run/admin/password
GF_USERS_ALLOW_SIGN_UP: 'false'
GF_AUTH_ANONYMOUS_ENABLED: 'false'
GF_ANALYTICS_REPORTING_ENABLED: 'false'
GF_ANALYTICS_CHECK_FOR_UPDATES: 'false'
GF_PLUGINS_PREINSTALL_DISABLED: 'true'
volumes:
- type: volume
source: grafana_data
target: /var/lib/grafana
volume:
nocopy: true
- ./secrets/grafana-admin:/run/admin:ro
- ./secrets/grafana-datasources:/etc/grafana/provisioning/datasources:ro
- ./infra/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
- ./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro
ports:
- 127.0.0.1:3443:3443
grafana-tls:
image: haproxy:3.0.12-alpine
cpus: 0.25
mem_limit: 64m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: unless-stopped
user: 65532:65532
volumes:
- ./secrets/grafana:/run/identity:ro
- ./infra/tls/grafana.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
network_mode: service:grafana
depends_on:
- grafana
audit:
image: mtusi2026lab7-api:local
networks:
- backend
cpus: 0.5
mem_limit: 256m
read_only: true
cap_drop: *drop_all_capabilities
security_opt: *no_new_privileges
tmpfs: *runtime_tmpfs
restart: 'no'
profiles:
- tools
user: 1000:1000
entrypoint:
- python
command:
- /audit/internal.py
volumes:
- ./student-tests:/audit:ro
- ./secrets:/audit-secrets:ro
- ./evidence:/evidence
- ./tests:/tests:ro
- ./contracts:/contracts:ro
- ./lab.json:/lab.json:ro
healthcheck:
disable: true
networks:
backend:
internal: true
edge: {}
volumes:
postgres_data: {}
redis_data: {}
broker_data: {}
s3_data: {}
bao_data: {}
prometheus_data: {}
loki_data: {}
tempo_data: {}
grafana_data: {}