forked from mtusi2026/mtusi2026lab7
lab7
This commit is contained in:
+451
@@ -0,0 +1,451 @@
|
||||
services:
|
||||
broker:
|
||||
image: rabbitmq:3.13.7-alpine
|
||||
environment:
|
||||
RABBITMQ_DEFAULT_USER: lab
|
||||
RABBITMQ_DEFAULT_PASS: ${BROKER_PASSWORD:?run bootstrap}
|
||||
volumes:
|
||||
- broker_data:/var/lib/rabbitmq
|
||||
- ./infra/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro
|
||||
- ./secrets/broker:/tls/server:ro
|
||||
- ./secrets/ca.crt:/tls/ca.crt:ro
|
||||
restart: unless-stopped
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 768m
|
||||
cpus: 1.0
|
||||
dispatcher:
|
||||
build: .
|
||||
environment:
|
||||
S3_ENDPOINT: https://s3:8443
|
||||
S3_BUCKET: messenger-attachments
|
||||
OTEL_SERVICE_NAME: messenger-worker
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: https://otel-collector:4317
|
||||
DEPLOYMENT_ENV: lab
|
||||
BAO_ROLE: worker
|
||||
BAO_ADDR: https://bao:8200
|
||||
depends_on: &id001
|
||||
s3-init:
|
||||
condition: service_completed_successfully
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
otel-collector:
|
||||
condition: service_started
|
||||
bao:
|
||||
condition: service_started
|
||||
restart: unless-stopped
|
||||
stop_grace_period: 12s
|
||||
healthcheck:
|
||||
disable: true
|
||||
command:
|
||||
- python
|
||||
- worker.py
|
||||
- dispatch
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 768m
|
||||
cpus: 1.0
|
||||
cap_drop:
|
||||
- ALL
|
||||
volumes:
|
||||
- ./secrets/ca.crt:/tls/ca.crt:ro
|
||||
- ./secrets/worker:/identity:ro
|
||||
entrypoint:
|
||||
- python
|
||||
- scripts/bao_exec.py
|
||||
worker:
|
||||
build: .
|
||||
environment:
|
||||
S3_ENDPOINT: https://s3:8443
|
||||
S3_BUCKET: messenger-attachments
|
||||
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5}
|
||||
OTEL_SERVICE_NAME: messenger-worker
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: https://otel-collector:4317
|
||||
DEPLOYMENT_ENV: lab
|
||||
BAO_ROLE: worker
|
||||
BAO_ADDR: https://bao:8200
|
||||
depends_on: *id001
|
||||
restart: unless-stopped
|
||||
stop_grace_period: 12s
|
||||
healthcheck:
|
||||
disable: true
|
||||
command:
|
||||
- python
|
||||
- worker.py
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 768m
|
||||
cpus: 1.0
|
||||
cap_drop:
|
||||
- ALL
|
||||
volumes:
|
||||
- ./secrets/ca.crt:/tls/ca.crt:ro
|
||||
- ./secrets/worker:/identity:ro
|
||||
entrypoint:
|
||||
- python
|
||||
- scripts/bao_exec.py
|
||||
s3:
|
||||
image: chrislusf/seaweedfs:3.80
|
||||
command:
|
||||
- server
|
||||
- -dir=/data
|
||||
- -ip=127.0.0.1
|
||||
- -ip.bind=127.0.0.1
|
||||
- -s3
|
||||
- -s3.config=/etc/seaweedfs/s3.json
|
||||
- -s3.port=8333
|
||||
|
||||
volumes:
|
||||
- s3_data:/data
|
||||
- ./secrets/s3.json:/etc/seaweedfs/s3.json:ro
|
||||
- ./secrets/s3:/tls/server:ro
|
||||
|
||||
restart: unless-stopped
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 768m
|
||||
cpus: 1.0
|
||||
s3-tls:
|
||||
image: nginx:1.27.5-alpine
|
||||
network_mode: "service:s3"
|
||||
depends_on:
|
||||
- s3
|
||||
volumes:
|
||||
- ./infra/s3-tls.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
- ./secrets/s3:/tls/server:ro
|
||||
restart: unless-stopped
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 128m
|
||||
cpus: 0.5
|
||||
s3-init:
|
||||
build: .
|
||||
volumes:
|
||||
- ./scripts/init_bucket.py:/app/scripts/init_bucket.py:ro
|
||||
- ./secrets/ca.crt:/tls/ca.crt:ro
|
||||
- ./secrets/operator:/identity:ro
|
||||
command:
|
||||
- python
|
||||
- scripts/init_bucket.py
|
||||
depends_on:
|
||||
s3:
|
||||
condition: service_started
|
||||
bao:
|
||||
condition: service_started
|
||||
environment:
|
||||
S3_ENDPOINT: https://s3:8443
|
||||
S3_BUCKET: messenger-attachments
|
||||
BAO_ROLE: operator
|
||||
BAO_ADDR: https://bao:8200
|
||||
restart: 'no'
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 768m
|
||||
cpus: 1.0
|
||||
cap_drop:
|
||||
- ALL
|
||||
entrypoint:
|
||||
- python
|
||||
- scripts/bao_exec.py
|
||||
postgres:
|
||||
image: postgres:16.8-alpine
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?run bootstrap}
|
||||
POSTGRES_DB: ${POSTGRES_DB:-messenger}
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
- ./secrets/postgres:/tls:ro
|
||||
- ./scripts/postgres-entrypoint.sh:/postgres-entrypoint.sh:ro
|
||||
- ./infra/pg_hba.conf:/etc/pg_hba.conf:ro
|
||||
entrypoint: ["/bin/sh", "/postgres-entrypoint.sh"]
|
||||
command:
|
||||
- postgres
|
||||
- -c
|
||||
- ssl=on
|
||||
- -c
|
||||
- hba_file=/etc/pg_hba.conf
|
||||
- -c
|
||||
- ssl_cert_file=/var/lib/postgresql/tls/server.crt
|
||||
- -c
|
||||
- ssl_key_file=/var/lib/postgresql/tls/server.key
|
||||
healthcheck:
|
||||
test:
|
||||
- CMD-SHELL
|
||||
- pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB
|
||||
interval: 3s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 768m
|
||||
cpus: 1.0
|
||||
migrate:
|
||||
build: .
|
||||
command:
|
||||
- python
|
||||
- migrate.py
|
||||
environment:
|
||||
BAO_ROLE: operator
|
||||
BAO_ADDR: https://bao:8200
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
bao:
|
||||
condition: service_started
|
||||
restart: 'no'
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 768m
|
||||
cpus: 1.0
|
||||
cap_drop:
|
||||
- ALL
|
||||
volumes:
|
||||
- ./secrets/ca.crt:/tls/ca.crt:ro
|
||||
- ./secrets/operator:/identity:ro
|
||||
entrypoint:
|
||||
- python
|
||||
- scripts/bao_exec.py
|
||||
api1:
|
||||
build: .
|
||||
environment:
|
||||
INSTANCE_ID: api1
|
||||
OTEL_SERVICE_NAME: messenger-api
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: https://otel-collector:4317
|
||||
DEPLOYMENT_ENV: lab
|
||||
S3_ENDPOINT: https://s3:8443
|
||||
S3_BUCKET: messenger-attachments
|
||||
BAO_ROLE: api
|
||||
BAO_ADDR: https://bao:8200
|
||||
depends_on: *id001
|
||||
restart: unless-stopped
|
||||
stop_grace_period: 12s
|
||||
healthcheck: &id002
|
||||
test:
|
||||
- CMD
|
||||
- python
|
||||
- -c
|
||||
- import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready',timeout=2)
|
||||
interval: 3s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
start_period: 5s
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 768m
|
||||
cpus: 1.0
|
||||
cap_drop:
|
||||
- ALL
|
||||
volumes:
|
||||
- ./secrets/ca.crt:/tls/ca.crt:ro
|
||||
- ./secrets/api:/identity:ro
|
||||
entrypoint:
|
||||
- python
|
||||
- scripts/bao_exec.py
|
||||
command:
|
||||
- uvicorn
|
||||
- main:app
|
||||
- --host
|
||||
- 127.0.0.1
|
||||
- --port
|
||||
- '8080'
|
||||
api2:
|
||||
build: .
|
||||
environment:
|
||||
INSTANCE_ID: api2
|
||||
OTEL_SERVICE_NAME: messenger-api
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: https://otel-collector:4317
|
||||
DEPLOYMENT_ENV: lab
|
||||
S3_ENDPOINT: https://s3:8443
|
||||
S3_BUCKET: messenger-attachments
|
||||
BAO_ROLE: api
|
||||
BAO_ADDR: https://bao:8200
|
||||
depends_on: *id001
|
||||
restart: unless-stopped
|
||||
stop_grace_period: 12s
|
||||
healthcheck: *id002
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 768m
|
||||
cpus: 1.0
|
||||
cap_drop:
|
||||
- ALL
|
||||
volumes:
|
||||
- ./secrets/ca.crt:/tls/ca.crt:ro
|
||||
- ./secrets/api:/identity:ro
|
||||
entrypoint:
|
||||
- python
|
||||
- scripts/bao_exec.py
|
||||
command:
|
||||
- uvicorn
|
||||
- main:app
|
||||
- --host
|
||||
- 127.0.0.1
|
||||
- --port
|
||||
- '8080'
|
||||
otel-collector:
|
||||
image: otel/opentelemetry-collector-contrib:0.120.0
|
||||
command:
|
||||
- --config=/etc/otelcol-contrib/config.yaml
|
||||
volumes:
|
||||
- ./infra/otel/collector.yaml:/etc/otelcol-contrib/config.yaml:ro
|
||||
- ./secrets/otel-collector:/tls/server:ro
|
||||
- ./secrets/ca.crt:/tls/ca.crt:ro
|
||||
depends_on:
|
||||
- prometheus
|
||||
- loki
|
||||
- tempo
|
||||
restart: unless-stopped
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 768m
|
||||
cpus: 1.0
|
||||
prometheus:
|
||||
image: prom/prometheus:v3.2.1
|
||||
command:
|
||||
- --config.file=/etc/prometheus/prometheus.yml
|
||||
- --storage.tsdb.path=/prometheus
|
||||
- --web.enable-lifecycle
|
||||
- --web.config.file=/etc/prometheus/web.yml
|
||||
volumes:
|
||||
- ./secrets/prometheus:/tls/server:ro
|
||||
- ./secrets/ca.crt:/tls/ca.crt:ro
|
||||
- ./infra/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
||||
- ./infra/prometheus/alerts.yml:/etc/prometheus/alerts.yml:ro
|
||||
- ./infra/prometheus/web.yml:/etc/prometheus/web.yml:ro
|
||||
- prometheus_data:/prometheus
|
||||
restart: unless-stopped
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 768m
|
||||
cpus: 1.0
|
||||
loki:
|
||||
image: grafana/loki:3.4.2
|
||||
command:
|
||||
- -config.file=/etc/loki/local-config.yaml
|
||||
volumes:
|
||||
- ./secrets/loki:/tls/server:ro
|
||||
- ./secrets/ca.crt:/tls/ca.crt:ro
|
||||
- ./infra/loki/config.yaml:/etc/loki/local-config.yaml:ro
|
||||
- loki_data:/loki
|
||||
restart: unless-stopped
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 768m
|
||||
cpus: 1.0
|
||||
tempo:
|
||||
image: grafana/tempo:2.7.2
|
||||
command:
|
||||
- -config.file=/etc/tempo/config.yaml
|
||||
volumes:
|
||||
- ./secrets/tempo:/tls/server:ro
|
||||
- ./secrets/ca.crt:/tls/ca.crt:ro
|
||||
- ./infra/tempo/config.yaml:/etc/tempo/config.yaml:ro
|
||||
- tempo_data:/var/tempo
|
||||
restart: unless-stopped
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 768m
|
||||
cpus: 1.0
|
||||
grafana:
|
||||
image: grafana/grafana:11.5.2
|
||||
environment:
|
||||
GF_SECURITY_ADMIN_USER: ${GRAFANA_USER:-admin}
|
||||
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_PASSWORD:?run bootstrap}
|
||||
GF_USERS_ALLOW_SIGN_UP: 'false'
|
||||
volumes:
|
||||
- grafana_data:/var/lib/grafana
|
||||
- ./infra/grafana/provisioning:/etc/grafana/provisioning:ro
|
||||
- ./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro
|
||||
depends_on:
|
||||
- prometheus
|
||||
- loki
|
||||
- tempo
|
||||
restart: unless-stopped
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 768m
|
||||
cpus: 1.0
|
||||
ports:
|
||||
- 127.0.0.1:3007:3000
|
||||
lb:
|
||||
image: nginx:1.27.5-alpine
|
||||
volumes:
|
||||
- ./infra/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ./secrets/ca.crt:/tls/ca.crt:ro
|
||||
- ./secrets/lb:/tls/lb:ro
|
||||
- ./secrets/ingress:/tls/ingress:ro
|
||||
depends_on:
|
||||
api1-tls:
|
||||
condition: service_started
|
||||
api2-tls:
|
||||
condition: service_started
|
||||
restart: unless-stopped
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 768m
|
||||
cpus: 1.0
|
||||
ports:
|
||||
- 8443:8443
|
||||
api1-tls:
|
||||
image: nginx:1.27.5-alpine
|
||||
network_mode: service:api1
|
||||
depends_on:
|
||||
api1:
|
||||
condition: service_healthy
|
||||
volumes:
|
||||
- ./infra/api-tls.conf:/etc/nginx/nginx.conf:ro
|
||||
- ./secrets/ca.crt:/tls/ca.crt:ro
|
||||
- ./secrets/api-server:/tls/server:ro
|
||||
restart: unless-stopped
|
||||
mem_limit: 128m
|
||||
cpus: 0.5
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
api2-tls:
|
||||
image: nginx:1.27.5-alpine
|
||||
network_mode: service:api2
|
||||
depends_on:
|
||||
api2:
|
||||
condition: service_healthy
|
||||
volumes:
|
||||
- ./infra/api-tls.conf:/etc/nginx/nginx.conf:ro
|
||||
- ./secrets/ca.crt:/tls/ca.crt:ro
|
||||
- ./secrets/api-server:/tls/server:ro
|
||||
restart: unless-stopped
|
||||
mem_limit: 128m
|
||||
cpus: 0.5
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
bao:
|
||||
image: openbao/openbao:2.2.0
|
||||
command:
|
||||
- server
|
||||
- -config=/bao/config.hcl
|
||||
volumes:
|
||||
- ./infra/openbao/config.hcl:/bao/config.hcl:ro
|
||||
- ./secrets/bao:/tls:ro
|
||||
- bao_data_v2:/bao/data
|
||||
ports:
|
||||
- 127.0.0.1:8200:8200
|
||||
environment:
|
||||
BAO_DISABLE_MLOCK: 'true'
|
||||
cap_drop:
|
||||
- ALL
|
||||
cap_add:
|
||||
- SETGID
|
||||
- SETUID
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
mem_limit: 256m
|
||||
cpus: 0.5
|
||||
volumes:
|
||||
postgres_data: null
|
||||
s3_data: null
|
||||
broker_data: null
|
||||
prometheus_data: null
|
||||
loki_data: null
|
||||
tempo_data: null
|
||||
grafana_data: null
|
||||
bao_data: null
|
||||
bao_data_v2: null
|
||||
Reference in New Issue
Block a user