forked from mtusi2026/mtusi2026lab7
608 lines
15 KiB
YAML
608 lines
15 KiB
YAML
services:
|
|
postgres:
|
|
image: postgres:16.6-alpine
|
|
environment:
|
|
POSTGRES_DB: ${POSTGRES_DB:?}
|
|
POSTGRES_USER: ${POSTGRES_USER:?}
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?}
|
|
command:
|
|
- postgres
|
|
- -c
|
|
- max_connections=100
|
|
- -c
|
|
- shared_buffers=128MB
|
|
- -c
|
|
- ssl=on
|
|
- -c
|
|
- ssl_cert_file=/identity/cert.pem
|
|
- -c
|
|
- ssl_key_file=/tmp/server.key
|
|
- -c
|
|
- hba_file=/etc/postgres-hba.conf
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql/data
|
|
- .local/id/postgres:/identity:ro
|
|
- ./infra/pg_hba.conf:/etc/postgres-hba.conf:ro
|
|
- ./.local/roles.sql:/docker-entrypoint-initdb.d/010-roles.sql:ro
|
|
healthcheck:
|
|
test:
|
|
- CMD-SHELL
|
|
- pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB"
|
|
interval: 2s
|
|
timeout: 1s
|
|
retries: 30
|
|
cpus: 1.0
|
|
mem_limit: 512m
|
|
networks:
|
|
- mesh
|
|
entrypoint:
|
|
- /bin/sh
|
|
- -ec
|
|
- install -m 600 -o postgres /identity/key.pem /tmp/server.key; exec docker-entrypoint.sh
|
|
"$@"
|
|
- --
|
|
redis:
|
|
image: redis:7.4.1-alpine
|
|
command:
|
|
- redis-server
|
|
- --aclfile
|
|
- /etc/redis.acl
|
|
- --appendonly
|
|
- 'yes'
|
|
- --maxmemory
|
|
- 128mb
|
|
- --maxmemory-policy
|
|
- noeviction
|
|
- --port
|
|
- '0'
|
|
- --tls-port
|
|
- '6379'
|
|
- --tls-cert-file
|
|
- /identity/cert.pem
|
|
- --tls-key-file
|
|
- /identity/key.pem
|
|
- --tls-ca-cert-file
|
|
- /identity/ca.crt
|
|
- --tls-auth-clients
|
|
- 'no'
|
|
volumes:
|
|
- redis_data:/data
|
|
- .local/redis.acl:/etc/redis.acl:ro
|
|
- ./.local/id/redis:/identity:ro
|
|
healthcheck:
|
|
test:
|
|
- CMD-SHELL
|
|
- redis-cli --tls --cacert /identity/ca.crt --sni redis -h redis ping 2>&1 |
|
|
grep -q NOAUTH
|
|
interval: 2s
|
|
timeout: 1s
|
|
retries: 30
|
|
cpus: 0.5
|
|
mem_limit: 192m
|
|
networks:
|
|
mesh:
|
|
aliases:
|
|
- redis-tls
|
|
minio:
|
|
build:
|
|
context: ./infra/minio
|
|
dockerfile: Dockerfile
|
|
image: mtusi5-minio:2025-04-22-local
|
|
command:
|
|
- server
|
|
- --certs-dir
|
|
- /etc/minio/certs
|
|
- /data
|
|
- --console-address
|
|
- 127.0.0.1:9001
|
|
environment:
|
|
MINIO_ROOT_USER: ${MINIO_ROOT_USER:?}
|
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:?}
|
|
MINIO_API_STALE_UPLOADS_EXPIRY: 24h
|
|
MINIO_API_STALE_UPLOADS_CLEANUP_INTERVAL: 1h
|
|
volumes:
|
|
- minio_data:/data
|
|
- ./.local/id/minio:/identity:ro
|
|
- ./.local/id/minio/cert.pem:/etc/minio/certs/public.crt:ro
|
|
- ./.local/id/minio/key.pem:/etc/minio/certs/private.key:ro
|
|
- ./.local/id/minio/ca.crt:/etc/minio/certs/CAs/lab.crt:ro
|
|
healthcheck:
|
|
test:
|
|
- CMD
|
|
- curl
|
|
- -fsS
|
|
- --cacert
|
|
- /identity/ca.crt
|
|
- https://minio:9000/minio/health/live
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
start_period: 10s
|
|
cpus: 1.0
|
|
mem_limit: 768m
|
|
restart: unless-stopped
|
|
networks:
|
|
mesh:
|
|
aliases:
|
|
- minio-tls
|
|
minio-init:
|
|
image: mtusi5-minio:2025-04-22-local
|
|
pull_policy: never
|
|
depends_on:
|
|
minio:
|
|
condition: service_healthy
|
|
environment:
|
|
MINIO_ROOT_USER: ${MINIO_ROOT_USER:?}
|
|
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:?}
|
|
S3_BUCKET: ${S3_BUCKET:?}
|
|
S3_ACCESS_KEY: ${S3_ACCESS_KEY:?}
|
|
S3_SECRET_KEY: ${S3_SECRET_KEY:?}
|
|
WORKER_S3_PASSWORD: ${WORKER_S3_PASSWORD:?}
|
|
volumes:
|
|
- ./infra/minio/bootstrap.sh:/bootstrap/bootstrap.sh:ro
|
|
- ./.local/ca.crt:/root/.mc/certs/CAs/lab.crt:ro
|
|
entrypoint:
|
|
- /bin/sh
|
|
- /bootstrap/bootstrap.sh
|
|
restart: 'no'
|
|
networks:
|
|
- mesh
|
|
cpus: 0.5
|
|
mem_limit: 128m
|
|
rabbitmq:
|
|
image: rabbitmq:4.1.4-alpine
|
|
hostname: rabbitmq
|
|
volumes:
|
|
- rabbitmq_data:/var/lib/rabbitmq
|
|
- .local/rabbit.json:/etc/rabbitmq/definitions.json:ro
|
|
- ./infra/rabbit.conf:/etc/rabbitmq/rabbitmq.conf:ro
|
|
- ./.local/id/rabbitmq:/identity:ro
|
|
healthcheck:
|
|
test:
|
|
- CMD
|
|
- rabbitmq-diagnostics
|
|
- -q
|
|
- ping
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 30
|
|
start_period: 30s
|
|
cpus: 1.0
|
|
mem_limit: 512m
|
|
restart: unless-stopped
|
|
networks:
|
|
mesh:
|
|
aliases:
|
|
- rabbitmq-tls
|
|
environment:
|
|
RABBITMQ_NODENAME: rabbit@localhost
|
|
ERL_EPMD_ADDRESS: 127.0.0.1
|
|
migrate:
|
|
image: flyway/flyway:10.20.1-alpine
|
|
command:
|
|
- -connectRetries=30
|
|
- migrate
|
|
environment:
|
|
FLYWAY_URL: jdbc:postgresql://postgres:5432/messenger?sslmode=verify-full&sslrootcert=/identity/ca.crt
|
|
FLYWAY_USER: ${POSTGRES_USER:?}
|
|
FLYWAY_PASSWORD: ${POSTGRES_PASSWORD:?}
|
|
volumes:
|
|
- ./java/src/main/resources/db/migration:/flyway/sql:ro
|
|
- .local/ca.crt:/identity/ca.crt:ro
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
cpus: 0.5
|
|
mem_limit: 384m
|
|
restart: 'no'
|
|
networks:
|
|
- mesh
|
|
api:
|
|
build: .
|
|
image: messenger7-app:local
|
|
environment:
|
|
DB_URL: jdbc:postgresql://postgres:5432/messenger?sslmode=verify-full&sslrootcert=/identity/ca.crt
|
|
DB_POOL_SIZE: ${DB_POOL_SIZE:-8}
|
|
REDIS_HOST: 127.0.0.1
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
FLYWAY_ENABLED: 'false'
|
|
S3_ENDPOINT: http://127.0.0.1:9000
|
|
S3_BUCKET: ${S3_BUCKET:?}
|
|
RABBITMQ_HOST: 127.0.0.1
|
|
WORKER_ENABLED: 'false'
|
|
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-3}
|
|
JOB_TIMEOUT_SECONDS: ${JOB_TIMEOUT_SECONDS:-120}
|
|
STAGING_RETENTION_SECONDS: ${STAGING_RETENTION_SECONDS:-604800}
|
|
UPLOAD_MAX_CONCURRENT: ${UPLOAD_MAX_CONCURRENT:-1}
|
|
UPLOAD_TEMP_DIR: /tmp/messenger-uploads
|
|
ATTACHMENT_CLEANUP_ENABLED: 'true'
|
|
ATTACHMENT_CLEANUP_GRACE_SECONDS: ${ATTACHMENT_CLEANUP_GRACE_SECONDS:-3600}
|
|
ATTACHMENT_CLEANUP_INTERVAL_MS: ${ATTACHMENT_CLEANUP_INTERVAL_MS:-300000}
|
|
ATTACHMENT_CLEANUP_INITIAL_DELAY_MS: ${ATTACHMENT_CLEANUP_INITIAL_DELAY_MS:-60000}
|
|
JAVA_TOOL_OPTIONS: -Djava.awt.headless=true
|
|
OTEL_SERVICE_NAME: messenger-api
|
|
OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:4318
|
|
SERVER_ADDRESS: 127.0.0.1
|
|
SERVICE_ROLE: api
|
|
SPRING_RABBITMQ_DYNAMIC: 'false'
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
redis:
|
|
condition: service_healthy
|
|
minio-init:
|
|
condition: service_completed_successfully
|
|
otel-collector:
|
|
condition: service_started
|
|
openbao:
|
|
condition: service_started
|
|
otel-collector-tls:
|
|
condition: service_started
|
|
rabbitmq:
|
|
condition: service_healthy
|
|
deploy:
|
|
replicas: ${API_REPLICAS:-2}
|
|
cpus: ${API_CPUS:-1.0}
|
|
mem_limit: ${API_MEMORY:-768m}
|
|
restart: unless-stopped
|
|
stop_grace_period: 20s
|
|
healthcheck:
|
|
test:
|
|
- CMD
|
|
- wget
|
|
- -qO-
|
|
- http://localhost:8080/health/ready
|
|
interval: 5s
|
|
timeout: 15s
|
|
start_period: 60s
|
|
retries: 3
|
|
networks:
|
|
- mesh
|
|
volumes:
|
|
- .local/id/api:/identity:ro
|
|
- ./infra/tls/api.cfg:/app/transport.cfg:ro
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
worker:
|
|
image: messenger7-app:local
|
|
pull_policy: never
|
|
environment:
|
|
DB_URL: jdbc:postgresql://postgres:5432/messenger?sslmode=verify-full&sslrootcert=/identity/ca.crt
|
|
DB_POOL_SIZE: ${DB_POOL_SIZE:-8}
|
|
REDIS_HOST: 127.0.0.1
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
FLYWAY_ENABLED: 'false'
|
|
S3_ENDPOINT: http://127.0.0.1:9000
|
|
S3_BUCKET: ${S3_BUCKET:?}
|
|
RABBITMQ_HOST: 127.0.0.1
|
|
WORKER_ENABLED: 'true'
|
|
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-3}
|
|
JOB_TIMEOUT_SECONDS: ${JOB_TIMEOUT_SECONDS:-120}
|
|
STAGING_RETENTION_SECONDS: ${STAGING_RETENTION_SECONDS:-604800}
|
|
UPLOAD_MAX_CONCURRENT: ${UPLOAD_MAX_CONCURRENT:-1}
|
|
UPLOAD_TEMP_DIR: /tmp/messenger-uploads
|
|
ATTACHMENT_CLEANUP_ENABLED: 'false'
|
|
ATTACHMENT_CLEANUP_GRACE_SECONDS: ${ATTACHMENT_CLEANUP_GRACE_SECONDS:-3600}
|
|
ATTACHMENT_CLEANUP_INTERVAL_MS: ${ATTACHMENT_CLEANUP_INTERVAL_MS:-300000}
|
|
ATTACHMENT_CLEANUP_INITIAL_DELAY_MS: ${ATTACHMENT_CLEANUP_INITIAL_DELAY_MS:-60000}
|
|
JAVA_TOOL_OPTIONS: -Djava.awt.headless=true
|
|
OTEL_SERVICE_NAME: messenger-worker
|
|
OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:4318
|
|
SERVER_ADDRESS: 127.0.0.1
|
|
SERVICE_ROLE: worker
|
|
SPRING_RABBITMQ_DYNAMIC: 'false'
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
minio-init:
|
|
condition: service_completed_successfully
|
|
rabbitmq:
|
|
condition: service_healthy
|
|
otel-collector:
|
|
condition: service_started
|
|
openbao:
|
|
condition: service_started
|
|
otel-collector-tls:
|
|
condition: service_started
|
|
cpus: 1.0
|
|
mem_limit: 768m
|
|
restart: unless-stopped
|
|
stop_grace_period: 20s
|
|
healthcheck:
|
|
test:
|
|
- CMD
|
|
- wget
|
|
- -qO-
|
|
- http://localhost:8080/health/live
|
|
interval: 5s
|
|
timeout: 5s
|
|
start_period: 60s
|
|
retries: 10
|
|
networks:
|
|
- mesh
|
|
volumes:
|
|
- .local/id/worker:/identity:ro
|
|
- ./infra/tls/worker.cfg:/app/transport.cfg:ro
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
lb:
|
|
image: nginx:1.28-alpine
|
|
ports:
|
|
- 127.0.0.1:8443:8443
|
|
networks:
|
|
- edge
|
|
- mesh
|
|
depends_on:
|
|
api:
|
|
condition: service_healthy
|
|
mem_limit: 96m
|
|
cpus: 0.5
|
|
volumes:
|
|
- .local/id/lb:/identity:ro
|
|
- ./infra/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
otel-collector:
|
|
image: otel/opentelemetry-collector-contrib:0.115.1
|
|
command:
|
|
- --config=/etc/otelcol/config.yaml
|
|
volumes:
|
|
- ./infra/observability/collector.yaml:/etc/otelcol/config.yaml:ro
|
|
- ./.local/id/otel-collector:/identity:ro
|
|
networks:
|
|
local-otel-collector:
|
|
ipv4_address: 172.29.123.3
|
|
mem_limit: 256m
|
|
restart: unless-stopped
|
|
depends_on:
|
|
- loki
|
|
- tempo
|
|
cpus: 0.5
|
|
prometheus:
|
|
image: prom/prometheus:v3.0.1
|
|
command:
|
|
- --config.file=/etc/prometheus/prometheus.yaml
|
|
- --storage.tsdb.path=/prometheus
|
|
- --storage.tsdb.retention.time=7d
|
|
volumes:
|
|
- ./infra/observability/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro
|
|
- prometheus_data:/prometheus
|
|
networks:
|
|
local-prometheus:
|
|
ipv4_address: 172.29.124.3
|
|
mem_limit: 384m
|
|
restart: unless-stopped
|
|
cpus: 0.5
|
|
loki:
|
|
image: grafana/loki:3.3.2
|
|
command:
|
|
- -config.file=/etc/loki/config.yaml
|
|
volumes:
|
|
- ./infra/observability/loki.yaml:/etc/loki/config.yaml:ro
|
|
- loki_data:/loki
|
|
networks:
|
|
local-loki:
|
|
ipv4_address: 172.29.125.3
|
|
mem_limit: 384m
|
|
restart: unless-stopped
|
|
cpus: 0.5
|
|
tempo:
|
|
image: grafana/tempo:2.6.1
|
|
user: 0:0
|
|
command:
|
|
- -config.file=/etc/tempo/config.yaml
|
|
volumes:
|
|
- ./infra/observability/tempo.yaml:/etc/tempo/config.yaml:ro
|
|
- tempo_data:/var/tempo
|
|
networks:
|
|
local-tempo:
|
|
ipv4_address: 172.29.126.3
|
|
mem_limit: 384m
|
|
restart: unless-stopped
|
|
cpus: 0.5
|
|
grafana:
|
|
image: grafana/grafana:11.4.0
|
|
environment:
|
|
GF_SECURITY_ADMIN_USER: ${GRAFANA_USER:-admin}
|
|
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD:?}
|
|
GF_USERS_ALLOW_SIGN_UP: 'false'
|
|
GF_ANALYTICS_REPORTING_ENABLED: 'false'
|
|
GF_ANALYTICS_CHECK_FOR_UPDATES: 'false'
|
|
volumes:
|
|
- grafana_data:/var/lib/grafana
|
|
- ./infra/observability/grafana/provisioning:/etc/grafana/provisioning:ro
|
|
- ./infra/observability/grafana/dashboards:/var/lib/grafana/dashboards:ro
|
|
networks:
|
|
local-grafana:
|
|
ipv4_address: 172.29.127.3
|
|
mem_limit: 384m
|
|
restart: unless-stopped
|
|
depends_on:
|
|
- prometheus
|
|
- loki
|
|
- tempo
|
|
healthcheck:
|
|
test:
|
|
- CMD-SHELL
|
|
- wget -qO- http://localhost:3000/api/health >/dev/null
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 30
|
|
cpus: 0.5
|
|
otel-collector-tls:
|
|
image: haproxy:3.0.5-alpine
|
|
user: 65534:65534
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
mem_limit: 64m
|
|
cpus: 0.25
|
|
networks:
|
|
local-otel-collector:
|
|
ipv4_address: 172.29.123.2
|
|
aliases:
|
|
- transport
|
|
mesh:
|
|
aliases:
|
|
- collector-egress
|
|
volumes:
|
|
- ./infra/tls/otel-collector.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
|
- .local/id/otel-collector:/identity:ro
|
|
prometheus-tls:
|
|
image: haproxy:3.0.5-alpine
|
|
user: 65534:65534
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
mem_limit: 64m
|
|
cpus: 0.25
|
|
networks:
|
|
mesh: {}
|
|
local-prometheus:
|
|
ipv4_address: 172.29.124.2
|
|
aliases:
|
|
- transport
|
|
volumes:
|
|
- ./infra/tls/prometheus.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
|
- .local/id/prometheus:/identity:ro
|
|
loki-tls:
|
|
image: haproxy:3.0.5-alpine
|
|
user: 65534:65534
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
mem_limit: 64m
|
|
cpus: 0.25
|
|
networks:
|
|
mesh: {}
|
|
local-loki:
|
|
ipv4_address: 172.29.125.2
|
|
aliases:
|
|
- transport
|
|
volumes:
|
|
- ./infra/tls/loki.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
|
- .local/id/loki:/identity:ro
|
|
tempo-tls:
|
|
image: haproxy:3.0.5-alpine
|
|
user: 65534:65534
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
mem_limit: 64m
|
|
cpus: 0.25
|
|
networks:
|
|
mesh: {}
|
|
local-tempo:
|
|
ipv4_address: 172.29.126.2
|
|
aliases:
|
|
- transport
|
|
volumes:
|
|
- ./infra/tls/tempo.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
|
- .local/id/tempo:/identity:ro
|
|
grafana-tls:
|
|
image: haproxy:3.0.5-alpine
|
|
user: 65534:65534
|
|
cap_drop:
|
|
- ALL
|
|
security_opt:
|
|
- no-new-privileges:true
|
|
mem_limit: 64m
|
|
cpus: 0.25
|
|
networks:
|
|
mesh: {}
|
|
local-grafana:
|
|
ipv4_address: 172.29.127.2
|
|
aliases:
|
|
- transport
|
|
edge: {}
|
|
volumes:
|
|
- ./infra/tls/grafana.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
|
- .local/id/grafana:/identity:ro
|
|
ports:
|
|
- 127.0.0.1:3443:3443
|
|
openbao:
|
|
image: quay.io/openbao/openbao:2.4.4
|
|
command:
|
|
- server
|
|
- -config=/config/server.hcl
|
|
environment:
|
|
BAO_ADDR: https://localhost:8200
|
|
BAO_CACERT: /identity/ca.crt
|
|
SKIP_SETCAP: 'true'
|
|
networks:
|
|
- edge
|
|
- mesh
|
|
ports:
|
|
- 127.0.0.1:8200:8200
|
|
volumes:
|
|
- bao_data:/openbao/file
|
|
- .local/id/openbao:/identity:ro
|
|
- ./infra/openbao/server.hcl:/config/server.hcl:ro
|
|
mem_limit: 256m
|
|
cpus: 0.5
|
|
probe:
|
|
profiles:
|
|
- checks
|
|
image: messenger7-app:local
|
|
entrypoint:
|
|
- python3
|
|
- /checks/internal_tls.py
|
|
networks:
|
|
- mesh
|
|
volumes:
|
|
- ./tests/internal_tls.py:/checks/internal_tls.py:ro
|
|
- ./.local/ca.crt:/probe/ca.crt:ro
|
|
- ./.local/id/lb:/probe/lb:ro
|
|
- ./.local/id/api:/probe/api:ro
|
|
- ./.local/id/worker:/probe/worker:ro
|
|
- ./.local/id/foreign:/probe/foreign:ro
|
|
cap_drop:
|
|
- ALL
|
|
mem_limit: 96m
|
|
cpus: 0.25
|
|
volumes:
|
|
postgres_data: null
|
|
redis_data: null
|
|
minio_data: null
|
|
rabbitmq_data: null
|
|
prometheus_data: null
|
|
loki_data: null
|
|
tempo_data: null
|
|
grafana_data: null
|
|
bao_data: null
|
|
networks:
|
|
mesh:
|
|
internal: true
|
|
edge: {}
|
|
local-otel-collector:
|
|
internal: true
|
|
ipam:
|
|
config:
|
|
- subnet: 172.29.123.0/28
|
|
local-prometheus:
|
|
internal: true
|
|
ipam:
|
|
config:
|
|
- subnet: 172.29.124.0/28
|
|
local-loki:
|
|
internal: true
|
|
ipam:
|
|
config:
|
|
- subnet: 172.29.125.0/28
|
|
local-tempo:
|
|
internal: true
|
|
ipam:
|
|
config:
|
|
- subnet: 172.29.126.0/28
|
|
local-grafana:
|
|
internal: true
|
|
ipam:
|
|
config:
|
|
- subnet: 172.29.127.0/28
|
|
name: messenger7 |