Реализовать ЛР 7 на оценку 3
This commit is contained in:
+302
-80
@@ -1,27 +1,81 @@
|
||||
x-runtime-environment: &runtime-environment
|
||||
BAO_ADDR: https://openbao:8200
|
||||
PGSSLMODE: verify-full
|
||||
PGSSLROOTCERT: /run/secrets/lab_ca
|
||||
TLS_CA_FILE: /run/secrets/lab_ca
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
||||
S3_ENDPOINT: https://s3:9000
|
||||
S3_REGION: us-east-1
|
||||
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
|
||||
|
||||
x-telemetry-proxy: &telemetry-proxy
|
||||
image: haproxy:3.2.26-alpine
|
||||
cpus: "0.25"
|
||||
mem_limit: 96m
|
||||
restart: unless-stopped
|
||||
|
||||
x-otel-environment: &otel-environment
|
||||
OTEL_SDK_DISABLED: ${OTEL_SDK_DISABLED:-false}
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://otel-collector:4318}
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: https://otel-collector:4318
|
||||
OTEL_EXPORTER_OTLP_CERTIFICATE: /run/secrets/lab_ca
|
||||
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE: /run/identity/public.crt
|
||||
OTEL_EXPORTER_OTLP_CLIENT_KEY: /run/identity/private.key
|
||||
OTEL_EXPORTER_OTLP_PROTOCOL: ${OTEL_EXPORTER_OTLP_PROTOCOL:-http/protobuf}
|
||||
OTEL_EXPORTER_OTLP_TIMEOUT: ${OTEL_EXPORTER_OTLP_TIMEOUT:-2}
|
||||
OTEL_SERVICE_VERSION: ${OTEL_SERVICE_VERSION:-1.6.0}
|
||||
OTEL_SERVICE_VERSION: ${OTEL_SERVICE_VERSION:-1.7.0}
|
||||
OTEL_DEPLOYMENT_ENVIRONMENT: ${OTEL_DEPLOYMENT_ENVIRONMENT:-lab}
|
||||
OTEL_BSP_MAX_QUEUE_SIZE: ${OTEL_BSP_MAX_QUEUE_SIZE:-2048}
|
||||
OTEL_BLRP_MAX_QUEUE_SIZE: ${OTEL_BLRP_MAX_QUEUE_SIZE:-2048}
|
||||
OTEL_METRIC_EXPORT_INTERVAL: ${OTEL_METRIC_EXPORT_INTERVAL:-5000}
|
||||
|
||||
services:
|
||||
openbao:
|
||||
image: openbao/openbao:2.5.0
|
||||
cpus: "0.5"
|
||||
mem_limit: 256m
|
||||
command: ["server", "-config=/openbao/config/bao.hcl"]
|
||||
ports:
|
||||
- "127.0.0.1:${BAO_PORT:-8200}:8200"
|
||||
environment:
|
||||
BAO_ADDR: https://localhost:8200
|
||||
BAO_CACERT: /run/secrets/lab_ca
|
||||
SKIP_SETCAP: "true"
|
||||
secrets: [lab_ca]
|
||||
volumes:
|
||||
- ./infra/openbao/bao.hcl:/openbao/config/bao.hcl:ro
|
||||
- ${LAB_SECRETS_DIR:-./secrets}/openbao:/run/tls:ro
|
||||
- openbao_data:/openbao/file
|
||||
healthcheck:
|
||||
test: ["CMD", "bao", "status"]
|
||||
interval: 3s
|
||||
timeout: 3s
|
||||
retries: 15
|
||||
restart: unless-stopped
|
||||
|
||||
postgres:
|
||||
image: postgres:17.4-alpine
|
||||
cpus: "1.0"
|
||||
mem_limit: 512m
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
POSTGRES_DB: ${POSTGRES_DB}
|
||||
POSTGRES_USER: messenger
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
||||
POSTGRES_DB: messenger
|
||||
secrets: [postgres_password]
|
||||
entrypoint:
|
||||
- /bin/sh
|
||||
- -ec
|
||||
- |
|
||||
install -d -o postgres -g postgres -m 0700 /run/postgres-tls
|
||||
install -o postgres -g postgres -m 0600 /run/tls/private.key /run/postgres-tls/private.key
|
||||
exec docker-entrypoint.sh postgres -c ssl=on \
|
||||
-c ssl_cert_file=/run/tls/public.crt -c ssl_key_file=/run/postgres-tls/private.key \
|
||||
-c hba_file=/etc/postgres/pg_hba.conf
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
- ./infra/postgres-hba.conf:/etc/postgres/pg_hba.conf:ro
|
||||
- ${LAB_SECRETS_DIR:-./secrets}/postgres:/run/tls:ro
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
||||
test: ["CMD", "pg_isready", "-h", "localhost", "-U", "messenger", "-d", "messenger"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
@@ -30,24 +84,40 @@ services:
|
||||
image: redis:7.4.2-alpine
|
||||
cpus: "0.25"
|
||||
mem_limit: 128m
|
||||
command: ["redis-server", "--appendonly", "yes", "--appendfsync", "always"]
|
||||
command: ["redis-server", "/run/secrets/redis_config"]
|
||||
secrets: [redis_config, redis_api_password, lab_ca]
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
- ${LAB_SECRETS_DIR:-./secrets}/redis:/run/tls:ro
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
test:
|
||||
- CMD-SHELL
|
||||
- |
|
||||
REDISCLI_AUTH=$$(cat /run/secrets/redis_api_password)
|
||||
export REDISCLI_AUTH
|
||||
redis-cli --user messenger_api --tls -h redis --sni redis --cacert /run/secrets/lab_ca ping | grep -qx PONG
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
|
||||
broker:
|
||||
image: rabbitmq:4.1.4-alpine
|
||||
hostname: ${BROKER_HOSTNAME:-broker}
|
||||
extra_hosts:
|
||||
- "${BROKER_HOSTNAME:-broker}:127.0.0.1"
|
||||
environment:
|
||||
ERL_EPMD_ADDRESS: 127.0.0.1
|
||||
cpus: "0.5"
|
||||
mem_limit: 384m
|
||||
environment:
|
||||
RABBITMQ_DEFAULT_USER: ${BROKER_USER:-messenger}
|
||||
RABBITMQ_DEFAULT_PASS: ${BROKER_PASSWORD:-change-me-rabbitmq}
|
||||
secrets:
|
||||
- lab_ca
|
||||
- broker_definitions
|
||||
- source: broker_config
|
||||
target: /etc/rabbitmq/conf.d/30-lab.conf
|
||||
volumes:
|
||||
- broker_data:/var/lib/rabbitmq
|
||||
- ./infra/rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins:ro
|
||||
- ${LAB_SECRETS_DIR:-./secrets}/broker:/run/tls:ro
|
||||
healthcheck:
|
||||
test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]
|
||||
interval: 5s
|
||||
@@ -59,13 +129,16 @@ services:
|
||||
user: "0"
|
||||
cpus: "0.5"
|
||||
mem_limit: 256m
|
||||
command: ["server", "/data", "--console-address", ":9001"]
|
||||
command: ["server", "/data", "--console-address", ":9001", "--certs-dir", "/run/tls"]
|
||||
environment:
|
||||
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-local-minio-admin}
|
||||
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-change-me-minio-root}
|
||||
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
|
||||
MINIO_ROOT_USER_FILE: /run/secrets/s3_root_user
|
||||
MINIO_ROOT_PASSWORD_FILE: /run/secrets/s3_root_password
|
||||
MC_HOST_local: https://s3:9000
|
||||
SSL_CERT_FILE: /run/secrets/lab_ca
|
||||
secrets: [s3_root_user, s3_root_password, lab_ca]
|
||||
volumes:
|
||||
- s3_data:/data
|
||||
- ${LAB_SECRETS_DIR:-./secrets}/s3:/run/tls:ro
|
||||
healthcheck:
|
||||
test: ["CMD", "mc", "ready", "local"]
|
||||
interval: 5s
|
||||
@@ -80,21 +153,26 @@ services:
|
||||
command:
|
||||
- |
|
||||
set -eu
|
||||
mc alias set local http://s3:9000 "$$MINIO_ROOT_USER" "$$MINIO_ROOT_PASSWORD"
|
||||
root_user=$$(cat /run/secrets/s3_root_user)
|
||||
root_password=$$(cat /run/secrets/s3_root_password)
|
||||
mc alias set local https://s3:9000 "$$root_user" "$$root_password"
|
||||
mc mb --ignore-existing local/"$$S3_BUCKET"
|
||||
mc anonymous set none local/"$$S3_BUCKET"
|
||||
mc admin user info local "$$S3_ACCESS_KEY_ID" >/dev/null 2>&1 || mc admin user add local "$$S3_ACCESS_KEY_ID" "$$S3_SECRET_ACCESS_KEY"
|
||||
sed "s/BUCKET_NAME/$$S3_BUCKET/g" /policy/s3-api-policy.json >/tmp/s3-api-policy.json
|
||||
mc admin policy create local messenger-api /tmp/s3-api-policy.json
|
||||
mc admin policy attach local messenger-api --user "$$S3_ACCESS_KEY_ID"
|
||||
printf 'ready' | mc pipe "local/$$S3_BUCKET/originals/.health" >/dev/null
|
||||
for role in api worker; do
|
||||
secret_key=$$(cat "/run/secrets/s3_$${role}_secret")
|
||||
mc admin user add local "messenger-$$role" "$$secret_key"
|
||||
sed "s/BUCKET_NAME/$$S3_BUCKET/g" "/policy/s3-$$role-policy.json" >"/tmp/s3-$$role-policy.json"
|
||||
mc admin policy create local "messenger-$$role" "/tmp/s3-$$role-policy.json"
|
||||
mc admin policy attach local "messenger-$$role" --user "messenger-$$role"
|
||||
done
|
||||
environment:
|
||||
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-local-minio-admin}
|
||||
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-change-me-minio-root}
|
||||
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
|
||||
S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-messenger-api}
|
||||
S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-change-me-minio-api}
|
||||
SSL_CERT_FILE: /run/secrets/lab_ca
|
||||
secrets: [s3_root_user, s3_root_password, s3_api_secret, s3_worker_secret, lab_ca]
|
||||
volumes:
|
||||
- ./infra/s3-api-policy.json:/policy/s3-api-policy.json:ro
|
||||
- ./infra/s3-worker-policy.json:/policy/s3-worker-policy.json:ro
|
||||
depends_on:
|
||||
s3:
|
||||
condition: service_healthy
|
||||
@@ -106,50 +184,78 @@ services:
|
||||
mem_limit: 256m
|
||||
command: ["alembic", "upgrade", "head"]
|
||||
environment:
|
||||
DATABASE_URL: ${DATABASE_URL}
|
||||
REDIS_URL: ${REDIS_URL}
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS}
|
||||
S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-messenger-api}
|
||||
S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-change-me-minio-api}
|
||||
BROKER_URL: ${BROKER_URL}
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
PGSSLMODE: verify-full
|
||||
PGSSLROOTCERT: /run/secrets/lab_ca
|
||||
secrets: [database_url, lab_ca]
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
restart: "no"
|
||||
|
||||
api:
|
||||
build: .
|
||||
cpus: "0.5"
|
||||
mem_limit: 256m
|
||||
db-permissions:
|
||||
image: postgres:17.4-alpine
|
||||
cpus: "0.25"
|
||||
mem_limit: 96m
|
||||
entrypoint: ["/bin/sh", "-ec"]
|
||||
command:
|
||||
- |
|
||||
PGPASSWORD=$$(cat /run/secrets/postgres_password)
|
||||
export PGPASSWORD
|
||||
psql -h postgres -U messenger -d messenger -X -v ON_ERROR_STOP=1 --single-transaction \
|
||||
-f /run/secrets/postgres_roles -f /etc/postgres/grants.sql >/dev/null
|
||||
environment:
|
||||
<<: *otel-environment
|
||||
OTEL_SERVICE_NAME: messenger-api
|
||||
DATABASE_URL: ${DATABASE_URL}
|
||||
REDIS_URL: ${REDIS_URL}
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS}
|
||||
LOG_LEVEL: ${LOG_LEVEL:-info}
|
||||
S3_ENDPOINT: ${S3_ENDPOINT:-http://s3:9000}
|
||||
S3_REGION: ${S3_REGION:-us-east-1}
|
||||
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
|
||||
S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-messenger-api}
|
||||
S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-change-me-minio-api}
|
||||
MAX_UPLOAD_BYTES: ${MAX_UPLOAD_BYTES:-10485760}
|
||||
MAX_IMAGE_PIXELS: ${MAX_IMAGE_PIXELS:-40000000}
|
||||
BROKER_URL: ${BROKER_URL}
|
||||
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5}
|
||||
expose:
|
||||
- "8080"
|
||||
deploy:
|
||||
replicas: 2
|
||||
PGSSLMODE: verify-full
|
||||
PGSSLROOTCERT: /run/secrets/lab_ca
|
||||
secrets: [postgres_password, postgres_roles, lab_ca]
|
||||
volumes:
|
||||
- ./infra/postgres-grants.sql:/etc/postgres/grants.sql:ro
|
||||
depends_on:
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
restart: "no"
|
||||
|
||||
api:
|
||||
build: .
|
||||
security_opt: [no-new-privileges:true]
|
||||
cap_drop: [ALL]
|
||||
cpus: "0.5"
|
||||
mem_limit: 256m
|
||||
environment:
|
||||
<<: [*runtime-environment, *otel-environment]
|
||||
OTEL_SERVICE_NAME: messenger-api
|
||||
BAO_ROLE: api
|
||||
LOG_LEVEL: ${LOG_LEVEL:-info}
|
||||
LOGIN_LIMIT: ${LOGIN_LIMIT:-20}
|
||||
LOGIN_WINDOW_SECONDS: ${LOGIN_WINDOW_SECONDS:-60}
|
||||
REQUEST_MAX_BYTES: ${REQUEST_MAX_BYTES:-65536}
|
||||
MAX_UPLOAD_BYTES: ${MAX_UPLOAD_BYTES:-10485760}
|
||||
MAX_IMAGE_PIXELS: ${MAX_IMAGE_PIXELS:-40000000}
|
||||
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5}
|
||||
TLS_CERT_FILE: /run/secrets/api_cert
|
||||
TLS_KEY_FILE: /run/secrets/api_key
|
||||
TLS_LB_CERT_FILE: /run/secrets/lb_cert
|
||||
ARGON2_MEMORY_KIB: ${ARGON2_MEMORY_KIB:-19456}
|
||||
ARGON2_ITERATIONS: ${ARGON2_ITERATIONS:-2}
|
||||
ARGON2_PARALLELISM: ${ARGON2_PARALLELISM:-1}
|
||||
secrets: [lab_ca, api_cert, api_key, lb_cert]
|
||||
volumes:
|
||||
- ${LAB_SECRETS_DIR:-./secrets}/messenger-api:/run/identity:ro
|
||||
expose:
|
||||
- "8443"
|
||||
deploy:
|
||||
replicas: 2
|
||||
depends_on:
|
||||
db-permissions:
|
||||
condition: service_completed_successfully
|
||||
openbao:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
s3-bootstrap:
|
||||
condition: service_completed_successfully
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=3).read()"]
|
||||
test: ["CMD", "python", "-c", "import socket; socket.create_connection(('127.0.0.1', 8443), timeout=2).close()"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 5
|
||||
@@ -157,26 +263,27 @@ services:
|
||||
|
||||
publisher:
|
||||
build: .
|
||||
init: true
|
||||
stop_signal: SIGINT
|
||||
security_opt: [no-new-privileges:true]
|
||||
cap_drop: [ALL]
|
||||
command: ["python", "-m", "app.jobs.publisher"]
|
||||
cpus: "0.25"
|
||||
mem_limit: 192m
|
||||
environment:
|
||||
<<: *otel-environment
|
||||
<<: [*runtime-environment, *otel-environment]
|
||||
OTEL_SERVICE_NAME: messenger-publisher
|
||||
DATABASE_URL: ${DATABASE_URL}
|
||||
REDIS_URL: ${REDIS_URL}
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS}
|
||||
S3_ENDPOINT: ${S3_ENDPOINT:-http://s3:9000}
|
||||
S3_REGION: ${S3_REGION:-us-east-1}
|
||||
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
|
||||
S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-messenger-api}
|
||||
S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-change-me-minio-api}
|
||||
BROKER_URL: ${BROKER_URL}
|
||||
BAO_ROLE: publisher
|
||||
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5}
|
||||
JOB_LEASE_SECONDS: ${JOB_LEASE_SECONDS:-90}
|
||||
secrets: [lab_ca]
|
||||
volumes:
|
||||
- ${LAB_SECRETS_DIR:-./secrets}/messenger-publisher:/run/identity:ro
|
||||
depends_on:
|
||||
migrate:
|
||||
db-permissions:
|
||||
condition: service_completed_successfully
|
||||
openbao:
|
||||
condition: service_healthy
|
||||
broker:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
@@ -189,23 +296,19 @@ services:
|
||||
|
||||
worker:
|
||||
build: .
|
||||
init: true
|
||||
stop_signal: SIGINT
|
||||
security_opt: [no-new-privileges:true]
|
||||
cap_drop: [ALL]
|
||||
command: ["python", "-m", "app.jobs.worker"]
|
||||
cpus: "1.0"
|
||||
mem_limit: 768m
|
||||
environment:
|
||||
<<: *otel-environment
|
||||
<<: [*runtime-environment, *otel-environment]
|
||||
OTEL_SERVICE_NAME: messenger-worker
|
||||
DATABASE_URL: ${DATABASE_URL}
|
||||
REDIS_URL: ${REDIS_URL}
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS}
|
||||
S3_ENDPOINT: ${S3_ENDPOINT:-http://s3:9000}
|
||||
S3_REGION: ${S3_REGION:-us-east-1}
|
||||
S3_BUCKET: ${S3_BUCKET:-messenger-attachments}
|
||||
S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY_ID:-messenger-api}
|
||||
S3_SECRET_ACCESS_KEY: ${S3_SECRET_ACCESS_KEY:-change-me-minio-api}
|
||||
BAO_ROLE: worker
|
||||
MAX_UPLOAD_BYTES: ${MAX_UPLOAD_BYTES:-10485760}
|
||||
MAX_IMAGE_PIXELS: ${MAX_IMAGE_PIXELS:-40000000}
|
||||
BROKER_URL: ${BROKER_URL}
|
||||
WORKER_CONCURRENCY: ${WORKER_CONCURRENCY:-2}
|
||||
WORKER_PREFETCH: ${WORKER_PREFETCH:-2}
|
||||
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5}
|
||||
@@ -217,9 +320,14 @@ services:
|
||||
THUMBNAIL_JPEG_QUALITY: ${THUMBNAIL_JPEG_QUALITY:-85}
|
||||
CROP_JPEG_QUALITY: ${CROP_JPEG_QUALITY:-85}
|
||||
OPTIMIZED_WEBP_QUALITY: ${OPTIMIZED_WEBP_QUALITY:-82}
|
||||
secrets: [lab_ca]
|
||||
volumes:
|
||||
- ${LAB_SECRETS_DIR:-./secrets}/messenger-worker:/run/identity:ro
|
||||
depends_on:
|
||||
migrate:
|
||||
db-permissions:
|
||||
condition: service_completed_successfully
|
||||
openbao:
|
||||
condition: service_healthy
|
||||
broker:
|
||||
condition: service_healthy
|
||||
s3-bootstrap:
|
||||
@@ -237,26 +345,42 @@ services:
|
||||
cpus: "0.25"
|
||||
mem_limit: 128m
|
||||
ports:
|
||||
- "${APP_PORT:-8080}:8080"
|
||||
- "127.0.0.1:${PUBLIC_PORT:-8443}:8443"
|
||||
secrets: [ingress_pem, lb_pem, lab_ca]
|
||||
volumes:
|
||||
- ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/health/live"]
|
||||
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8081/health/lb"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 5
|
||||
stop_grace_period: 5s
|
||||
|
||||
collector-tls:
|
||||
<<: *telemetry-proxy
|
||||
secrets:
|
||||
- lab_ca
|
||||
- source: otel_collector_pem
|
||||
target: telemetry_pem
|
||||
volumes:
|
||||
- ./infra/telemetry-tls/otel-collector.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
networks:
|
||||
default:
|
||||
aliases: [otel-collector]
|
||||
|
||||
otel-collector:
|
||||
network_mode: "service:collector-tls"
|
||||
image: otel/opentelemetry-collector-contrib:0.123.0
|
||||
cpus: "0.5"
|
||||
mem_limit: 256m
|
||||
command: ["--config=/etc/otelcol-contrib/collector.yaml"]
|
||||
volumes:
|
||||
- ./infra/otel/collector.yaml:/etc/otelcol-contrib/collector.yaml:ro
|
||||
- ${LAB_SECRETS_DIR:-./secrets}/telemetry-export:/run/identity:ro
|
||||
secrets: [lab_ca]
|
||||
depends_on:
|
||||
loki:
|
||||
condition: service_started
|
||||
@@ -264,24 +388,53 @@ services:
|
||||
condition: service_started
|
||||
restart: unless-stopped
|
||||
|
||||
prometheus-tls:
|
||||
<<: *telemetry-proxy
|
||||
secrets:
|
||||
- lab_ca
|
||||
- source: prometheus_pem
|
||||
target: telemetry_pem
|
||||
volumes:
|
||||
- ./infra/telemetry-tls/prometheus.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
networks:
|
||||
default:
|
||||
aliases: [prometheus]
|
||||
|
||||
prometheus:
|
||||
network_mode: "service:prometheus-tls"
|
||||
image: prom/prometheus:v3.2.1
|
||||
cpus: "0.5"
|
||||
mem_limit: 384m
|
||||
command:
|
||||
- --config.file=/etc/prometheus/prometheus.yml
|
||||
- --web.listen-address=127.0.0.1:19090
|
||||
- --storage.tsdb.path=/prometheus
|
||||
- --storage.tsdb.retention.time=7d
|
||||
- --storage.tsdb.retention.size=1GB
|
||||
volumes:
|
||||
- ./infra/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
||||
- prometheus_data:/prometheus
|
||||
- ${LAB_SECRETS_DIR:-./secrets}/telemetry-scrape:/run/identity:ro
|
||||
secrets: [lab_ca]
|
||||
depends_on:
|
||||
otel-collector:
|
||||
condition: service_started
|
||||
restart: unless-stopped
|
||||
|
||||
loki-tls:
|
||||
<<: *telemetry-proxy
|
||||
secrets:
|
||||
- lab_ca
|
||||
- source: loki_pem
|
||||
target: telemetry_pem
|
||||
volumes:
|
||||
- ./infra/telemetry-tls/loki.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
networks:
|
||||
default:
|
||||
aliases: [loki]
|
||||
|
||||
loki:
|
||||
network_mode: "service:loki-tls"
|
||||
image: grafana/loki:3.4.2
|
||||
user: "0"
|
||||
cpus: "0.5"
|
||||
@@ -292,7 +445,20 @@ services:
|
||||
- loki_data:/loki
|
||||
restart: unless-stopped
|
||||
|
||||
tempo-tls:
|
||||
<<: *telemetry-proxy
|
||||
secrets:
|
||||
- lab_ca
|
||||
- source: tempo_pem
|
||||
target: telemetry_pem
|
||||
volumes:
|
||||
- ./infra/telemetry-tls/tempo.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
networks:
|
||||
default:
|
||||
aliases: [tempo]
|
||||
|
||||
tempo:
|
||||
network_mode: "service:tempo-tls"
|
||||
image: grafana/tempo:2.7.2
|
||||
user: "0"
|
||||
cpus: "0.5"
|
||||
@@ -307,16 +473,25 @@ services:
|
||||
image: grafana/grafana:11.6.0
|
||||
cpus: "0.5"
|
||||
mem_limit: 384m
|
||||
entrypoint: ["/bin/sh", "/etc/grafana/lab-entrypoint.sh"]
|
||||
environment:
|
||||
GF_SERVER_PROTOCOL: https
|
||||
GF_SERVER_CERT_FILE: /run/tls/public.crt
|
||||
GF_SERVER_CERT_KEY: /run/tls/private.key
|
||||
SSL_CERT_FILE: /run/secrets/lab_ca
|
||||
GF_SECURITY_ADMIN_USER: ${GRAFANA_ADMIN_USER:-admin}
|
||||
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD:-change-me-grafana}
|
||||
GF_SECURITY_ADMIN_PASSWORD__FILE: /run/secrets/grafana_admin_password
|
||||
GF_USERS_ALLOW_SIGN_UP: "false"
|
||||
GF_ANALYTICS_REPORTING_ENABLED: "false"
|
||||
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
|
||||
GF_PLUGINS_PREINSTALL_DISABLED: "true"
|
||||
ports:
|
||||
- "127.0.0.1:${GRAFANA_PORT:-3000}:3000"
|
||||
secrets: [grafana_admin_password, lab_ca]
|
||||
volumes:
|
||||
- ./infra/grafana/lab-entrypoint.sh:/etc/grafana/lab-entrypoint.sh:ro
|
||||
- ${LAB_SECRETS_DIR:-./secrets}/grafana:/run/tls:ro
|
||||
- ${LAB_SECRETS_DIR:-./secrets}/telemetry-query:/run/identity:ro
|
||||
- ./infra/grafana/provisioning:/etc/grafana/provisioning:ro
|
||||
- ./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro
|
||||
- ./infra/grafana/runbooks:/var/lib/grafana/runbooks:ro
|
||||
@@ -329,13 +504,14 @@ services:
|
||||
tempo:
|
||||
condition: service_started
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1:3000/api/health"]
|
||||
test: ["CMD-SHELL", "wget -q -O /dev/null https://localhost:3000/api/health"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 20
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
openbao_data:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
s3_data:
|
||||
@@ -344,3 +520,49 @@ volumes:
|
||||
loki_data:
|
||||
tempo_data:
|
||||
grafana_data:
|
||||
|
||||
secrets:
|
||||
lab_ca:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/ca.crt
|
||||
ingress_pem:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/ingress.pem
|
||||
lb_pem:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/lb.pem
|
||||
lb_cert:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/lb/public.crt
|
||||
api_cert:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/api/public.crt
|
||||
api_key:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/api/private.key
|
||||
postgres_password:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/postgres_password
|
||||
database_url:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/database_url
|
||||
postgres_roles:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/postgres_roles.sql
|
||||
redis_config:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/redis-lab.conf
|
||||
redis_api_password:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/redis_api_password
|
||||
broker_config:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/rabbitmq-lab.conf
|
||||
broker_definitions:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/rabbitmq-definitions.json
|
||||
s3_root_user:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/s3_root_user
|
||||
s3_root_password:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/s3_root_password
|
||||
s3_api_secret:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/s3_api_secret
|
||||
s3_worker_secret:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/s3_worker_secret
|
||||
grafana_admin_password:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/grafana_admin_password
|
||||
otel_collector_pem:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/otel-collector.pem
|
||||
prometheus_pem:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/prometheus.pem
|
||||
loki_pem:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/loki.pem
|
||||
tempo_pem:
|
||||
file: ${LAB_SECRETS_DIR:-./secrets}/tempo.pem
|
||||
|
||||
Reference in New Issue
Block a user