Выполнить лабораторную 7 по безопасности мессенджера
This commit is contained in:
+344
@@ -0,0 +1,344 @@
|
||||
x-app: &app
|
||||
image: mtusi2026lab7:local
|
||||
build: .
|
||||
restart: unless-stopped
|
||||
user: "10001:10001"
|
||||
read_only: true
|
||||
security_opt: [no-new-privileges:true]
|
||||
cap_drop: [ALL]
|
||||
tmpfs: ["/tmp:size=64m,mode=1777,noexec,nosuid,nodev", "/run/local:size=2m,mode=1777,noexec,nosuid,nodev"]
|
||||
networks: [app]
|
||||
pids_limit: 160
|
||||
stop_grace_period: 12s
|
||||
environment: &app-env
|
||||
OTEL_ENABLED: "1"
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
||||
DB_POOL_MAX: "5"
|
||||
MAX_IMAGE_PIXELS: "40000000"
|
||||
UPLOAD_CONCURRENCY: "1"
|
||||
JOB_TIMEOUT_SECONDS: "25"
|
||||
JOB_LEASE_SECONDS: "45"
|
||||
|
||||
x-proxy: &proxy
|
||||
image: haproxy:3.0.32-alpine3.24@sha256:457d1c0dcbf2dfc0e0358723c07df4410d30e7de42bec036b383cfede4a5dbe3
|
||||
user: "99:99"
|
||||
restart: unless-stopped
|
||||
command: ["-W", "-db", "-f", "/usr/local/etc/haproxy/haproxy.cfg"]
|
||||
read_only: true
|
||||
security_opt: [no-new-privileges:true]
|
||||
cap_drop: [ALL]
|
||||
tmpfs: ["/tmp:size=4m,mode=1777,noexec,nosuid,nodev"]
|
||||
cpus: 0.3
|
||||
mem_limit: 96m
|
||||
pids_limit: 32
|
||||
|
||||
x-observability: &observability
|
||||
restart: unless-stopped
|
||||
read_only: true
|
||||
cap_drop: [ALL]
|
||||
security_opt: [no-new-privileges:true]
|
||||
tmpfs: ["/tmp:size=32m,mode=1777,noexec,nosuid,nodev"]
|
||||
cpus: 0.5
|
||||
mem_limit: 300m
|
||||
pids_limit: 128
|
||||
|
||||
services:
|
||||
migrate:
|
||||
<<: *app
|
||||
restart: "no"
|
||||
environment:
|
||||
RUN_MIGRATIONS_ONLY: "1"
|
||||
command: ["/bin/sh", "-ec", 'export DATABASE_URL="$$(cat /run/operator/database_url)"; exec python server.py']
|
||||
volumes: ["./secrets/runtime/migrate:/run/operator:ro"]
|
||||
depends_on:
|
||||
postgres: {condition: service_healthy}
|
||||
cpus: 0.5
|
||||
mem_limit: 128m
|
||||
api:
|
||||
<<: *app
|
||||
scale: 2
|
||||
environment:
|
||||
<<: *app-env
|
||||
WORKLOAD_ID: api
|
||||
volumes: ["./secrets/runtime/api:/run/identity:ro"]
|
||||
command: ["python", "supervise.py", "python", "server.py"]
|
||||
depends_on:
|
||||
migrate: {condition: service_completed_successfully}
|
||||
openbao: {condition: service_started}
|
||||
cpus: 1.0
|
||||
mem_limit: 384m
|
||||
worker:
|
||||
<<: *app
|
||||
environment:
|
||||
<<: *app-env
|
||||
WORKLOAD_ID: worker
|
||||
volumes: ["./secrets/runtime/worker:/run/identity:ro"]
|
||||
command: ["python", "supervise.py", "python", "jobs.py"]
|
||||
depends_on:
|
||||
migrate: {condition: service_completed_successfully}
|
||||
openbao: {condition: service_started}
|
||||
cpus: 1.0
|
||||
mem_limit: 512m
|
||||
haproxy:
|
||||
<<: *proxy
|
||||
ports: ["127.0.0.1:${HTTPS_PORT:-8443}:8443"]
|
||||
networks: [front, app]
|
||||
volumes:
|
||||
- ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
- ./secrets/runtime/ingress:/run/identity:ro
|
||||
- ./secrets/runtime/edge:/run/edge:ro
|
||||
depends_on: [api]
|
||||
postgres:
|
||||
image: postgres:16.4-bookworm
|
||||
restart: unless-stopped
|
||||
networks: [app]
|
||||
environment:
|
||||
POSTGRES_USER: owner
|
||||
POSTGRES_DB: messenger
|
||||
POSTGRES_PASSWORD_FILE: /run/identity/postgres_password
|
||||
POSTGRES_INITDB_ARGS: --auth-host=scram-sha-256 --auth-local=trust
|
||||
entrypoint:
|
||||
- /bin/bash
|
||||
- -ec
|
||||
- |
|
||||
install -m 0600 -o postgres -g postgres /run/identity/service.key /run/pg/server.key
|
||||
exec docker-entrypoint.sh postgres -c ssl=on -c ssl_cert_file=/run/identity/service.crt \
|
||||
-c ssl_key_file=/run/pg/server.key -c ssl_min_protocol_version=TLSv1.2 -c hba_file=/etc/lab7-pg-hba.conf
|
||||
read_only: true
|
||||
security_opt: [no-new-privileges:true]
|
||||
cap_drop: [ALL]
|
||||
cap_add: [CHOWN, DAC_OVERRIDE, FOWNER, SETGID, SETUID]
|
||||
tmpfs: ["/tmp:size=32m,mode=1777", "/run/pg:size=2m,mode=0755", "/var/run/postgresql:size=2m,mode=1777"]
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
- ./infra/postgres-hba.conf:/etc/lab7-pg-hba.conf:ro
|
||||
- ./secrets/runtime/postgres:/run/identity:ro
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -h postgres -U owner -d messenger"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 25
|
||||
cpus: 1.0
|
||||
mem_limit: 448m
|
||||
rabbitmq:
|
||||
image: rabbitmq:4.0.5-management-alpine
|
||||
hostname: rabbitmq
|
||||
user: "999:999"
|
||||
restart: unless-stopped
|
||||
networks: [app]
|
||||
environment:
|
||||
ERL_EPMD_ADDRESS: 127.0.0.1
|
||||
ERL_INETRC: /etc/rabbitmq/lab-inetrc
|
||||
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: "+S 2:2 +A 4 -kernel inet_dist_use_interface {127,0,0,1}"
|
||||
read_only: true
|
||||
cap_drop: [ALL]
|
||||
security_opt: [no-new-privileges:true]
|
||||
tmpfs: ["/tmp:size=32m,mode=1777", "/var/log/rabbitmq:size=16m,mode=1777"]
|
||||
volumes:
|
||||
- rabbitmq_data:/var/lib/rabbitmq
|
||||
- ./secrets/runtime/rabbitmq:/run/identity:ro
|
||||
- ./infra/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro
|
||||
- ./infra/rabbitmq.json:/etc/rabbitmq/definitions.json:ro
|
||||
- ./infra/rabbitmq-plugins:/etc/rabbitmq/enabled_plugins:ro
|
||||
- ./infra/rabbitmq-inetrc:/etc/rabbitmq/lab-inetrc:ro
|
||||
cpus: 0.6
|
||||
mem_limit: 350m
|
||||
pids_limit: 160
|
||||
rustfs:
|
||||
<<: *proxy
|
||||
networks: [app]
|
||||
volumes:
|
||||
- ./infra/s3-proxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
- ./secrets/runtime/rustfs:/run/identity:ro
|
||||
s3-store:
|
||||
image: rustfs/rustfs:1.0.4
|
||||
restart: unless-stopped
|
||||
network_mode: service:rustfs
|
||||
entrypoint: ["/bin/sh", "-ec", '. /run/local-config/env; exec rustfs --address 127.0.0.1:19000 /data']
|
||||
environment:
|
||||
RUSTFS_CONSOLE_ENABLE: "false"
|
||||
RUSTFS_ADDRESS: 127.0.0.1:19000
|
||||
RUSTFS_OBS_LOG_DIRECTORY: /tmp
|
||||
read_only: true
|
||||
cap_drop: [ALL]
|
||||
security_opt: [no-new-privileges:true]
|
||||
tmpfs: ["/tmp:size=64m,mode=1777"]
|
||||
volumes:
|
||||
- rustfs_data:/data
|
||||
- ./secrets/runtime/s3-store:/run/local-config:ro
|
||||
cpus: 0.7
|
||||
mem_limit: 360m
|
||||
bucket-bootstrap:
|
||||
image: rustfs/rc:v0.1.37
|
||||
entrypoint: ["/bin/sh", "/bootstrap/bootstrap.sh"]
|
||||
networks: [app]
|
||||
environment:
|
||||
SSL_CERT_FILE: /run/local-config/ca.crt
|
||||
volumes:
|
||||
- ./infra/rustfs-bootstrap.sh:/bootstrap/bootstrap.sh:ro
|
||||
- ./infra/rustfs-api-policy.json:/bootstrap/api.json:ro
|
||||
- ./infra/rustfs-worker-policy.json:/bootstrap/worker.json:ro
|
||||
- ./secrets/runtime/s3-bootstrap:/run/local-config:ro
|
||||
security_opt: [no-new-privileges:true]
|
||||
cap_drop: [ALL]
|
||||
cpus: 0.3
|
||||
mem_limit: 96m
|
||||
profiles: [operator]
|
||||
openbao:
|
||||
image: openbao/openbao:2.7.3
|
||||
restart: unless-stopped
|
||||
command: ["server"]
|
||||
environment:
|
||||
SKIP_SETCAP: "true"
|
||||
ports: ["127.0.0.1:${BAO_PORT:-8277}:8200"]
|
||||
networks: [front, app]
|
||||
security_opt: [no-new-privileges:true]
|
||||
cap_drop: [ALL]
|
||||
read_only: true
|
||||
tmpfs: ["/tmp:size=24m,mode=1777"]
|
||||
volumes:
|
||||
- bao_raft_data:/openbao/file
|
||||
- ./secrets/runtime/openbao:/run/identity:ro
|
||||
- ./infra/openbao/bao.hcl:/openbao/config/lab.hcl:ro
|
||||
cpus: 0.8
|
||||
mem_limit: 384m
|
||||
collector:
|
||||
<<: *proxy
|
||||
networks: [app, observability]
|
||||
volumes:
|
||||
- ./infra/telemetry-proxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
- ./secrets/runtime/collector:/run/identity:ro
|
||||
collector-core:
|
||||
<<: *observability
|
||||
image: otel/opentelemetry-collector-contrib:0.123.0
|
||||
network_mode: service:collector
|
||||
command: ["--config=/etc/otelcol/lab.yaml"]
|
||||
environment:
|
||||
GOMEMLIMIT: 160MiB
|
||||
volumes:
|
||||
- ./infra/otel/collector.yaml:/etc/otelcol/lab.yaml:ro
|
||||
- ./secrets/runtime/collector:/run/identity:ro
|
||||
prometheus:
|
||||
<<: *proxy
|
||||
networks: [observability]
|
||||
volumes:
|
||||
- ./infra/prometheus-proxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
- ./secrets/runtime/prometheus:/run/identity:ro
|
||||
prometheus-core:
|
||||
<<: *observability
|
||||
image: prom/prometheus:v3.3.0
|
||||
network_mode: service:prometheus
|
||||
command:
|
||||
- --config.file=/etc/prometheus/prometheus.yml
|
||||
- --web.listen-address=127.0.0.1:19090
|
||||
- --storage.tsdb.path=/prometheus
|
||||
- --storage.tsdb.retention.time=15d
|
||||
- --storage.tsdb.retention.size=512MB
|
||||
volumes:
|
||||
- ./infra/otel/prometheus.yaml:/etc/prometheus/prometheus.yml:ro
|
||||
- ./infra/otel/rules.yaml:/etc/prometheus/rules.yaml:ro
|
||||
- ./secrets/runtime/prometheus:/run/identity:ro
|
||||
- prometheus_data:/prometheus
|
||||
loki:
|
||||
<<: *proxy
|
||||
networks: [observability]
|
||||
volumes:
|
||||
- ./infra/loki-proxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
- ./secrets/runtime/loki:/run/identity:ro
|
||||
loki-core:
|
||||
<<: *observability
|
||||
image: grafana/loki:3.4.3
|
||||
network_mode: service:loki
|
||||
command: ["-config.file=/etc/loki/lab.yaml"]
|
||||
volumes:
|
||||
- ./infra/otel/loki.yaml:/etc/loki/lab.yaml:ro
|
||||
- loki_data:/loki
|
||||
tempo:
|
||||
<<: *proxy
|
||||
networks: [observability]
|
||||
volumes:
|
||||
- ./infra/tempo-proxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
- ./secrets/runtime/tempo:/run/identity:ro
|
||||
tempo-core:
|
||||
<<: *observability
|
||||
image: grafana/tempo:2.7.2
|
||||
network_mode: service:tempo
|
||||
command: ["-config.file=/etc/tempo/lab.yaml"]
|
||||
volumes:
|
||||
- ./infra/otel/tempo.yaml:/etc/tempo/lab.yaml:ro
|
||||
- tempo_data:/var/tempo
|
||||
grafana:
|
||||
<<: *observability
|
||||
image: grafana/grafana:11.6.1
|
||||
networks: [front, observability]
|
||||
ports: ["127.0.0.1:${GRAFANA_PORT:-3007}:3000"]
|
||||
entrypoint: ["/bin/sh", "-ec"]
|
||||
command:
|
||||
- |
|
||||
export LAB_TLS_CA="$$(cat /run/identity/ca.crt)"
|
||||
export LAB_TLS_CERT="$$(cat /run/identity/service.crt)"
|
||||
export LAB_TLS_KEY="$$(cat /run/identity/service.key)"
|
||||
exec /run.sh
|
||||
environment:
|
||||
GF_SERVER_PROTOCOL: https
|
||||
GF_SERVER_CERT_FILE: /run/identity/service.crt
|
||||
GF_SERVER_CERT_KEY: /run/identity/service.key
|
||||
GF_SECURITY_ADMIN_PASSWORD__FILE: /run/operator/grafana_password
|
||||
GF_SECURITY_COOKIE_SECURE: "true"
|
||||
GF_ANALYTICS_REPORTING_ENABLED: "false"
|
||||
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
|
||||
GF_PLUGINS_PREINSTALL_DISABLED: "true"
|
||||
volumes:
|
||||
- ./infra/otel/grafana/provisioning:/etc/grafana/provisioning:ro
|
||||
- ./infra/otel/grafana/dashboards:/var/lib/grafana/dashboards:ro
|
||||
- ./secrets/runtime/grafana:/run/identity:ro
|
||||
- ./secrets/runtime/grafana-config:/run/operator:ro
|
||||
- grafana_data:/var/lib/grafana
|
||||
|
||||
maintenance:
|
||||
<<: *app
|
||||
profiles: [operator]
|
||||
restart: "no"
|
||||
environment: {PYTHONPATH: /app}
|
||||
entrypoint: ["/bin/sh", "/app/scripts/maintenance.sh"]
|
||||
volumes:
|
||||
- ./secrets/runtime/migrate:/run/operator:ro
|
||||
- ./secrets/runtime/migrate:/run/identity:ro
|
||||
- ./secrets/runtime/s3-store:/run/s3:ro
|
||||
- ./scripts/maintenance.sh:/app/scripts/maintenance.sh:ro
|
||||
cpus: 0.5
|
||||
mem_limit: 192m
|
||||
|
||||
audit:
|
||||
<<: *app
|
||||
profiles: [operator]
|
||||
restart: "no"
|
||||
networks: [app, observability]
|
||||
command: ["python", "/audit/tls_matrix.py"]
|
||||
environment: {PYTHONPATH: /app}
|
||||
volumes:
|
||||
- ./student-tests:/audit:ro
|
||||
- ./secrets/runtime/auditor:/run/audit/auditor:ro
|
||||
- ./secrets/runtime/foreign:/run/audit/foreign:ro
|
||||
- ./secrets/runtime/api:/run/audit/api:ro
|
||||
- ./secrets/runtime/worker:/run/audit/worker:ro
|
||||
- ./secrets/runtime/ingress:/run/audit/ingress:ro
|
||||
- ./secrets/runtime/grafana:/run/audit/grafana:ro
|
||||
- ./secrets/runtime/collector:/run/audit/collector:ro
|
||||
- ./secrets/runtime/prometheus:/run/audit/prometheus:ro
|
||||
cpus: 0.6
|
||||
mem_limit: 192m
|
||||
|
||||
networks:
|
||||
front: {}
|
||||
app: {internal: true}
|
||||
observability: {internal: true}
|
||||
volumes:
|
||||
bao_raft_data:
|
||||
postgres_data:
|
||||
rabbitmq_data:
|
||||
rustfs_data:
|
||||
prometheus_data:
|
||||
loki_data:
|
||||
tempo_data:
|
||||
grafana_data:
|
||||
Reference in New Issue
Block a user