forked from mtusi2026/mtusi2026lab6
lab6
This commit is contained in:
+222
@@ -16,10 +16,21 @@ name: mtusi-messenger-lab6
|
||||
# and OOMs Docker Desktop's default VM.
|
||||
x-app: &app
|
||||
image: mtusi-messenger:lab6
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:18-alpine@sha256:77f585114c32fbca283dc835b0596f4e52b51b4c6662d7810b2f4084f60a1873
|
||||
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-messenger}
|
||||
@@ -44,6 +55,12 @@ services:
|
||||
|
||||
redis:
|
||||
image: redis:7.4-alpine@sha256:858f009f9709ce576febc734aa78b8f6d624b82571f9ddb6bda4377c833b3499
|
||||
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
command:
|
||||
- redis-server
|
||||
- --appendonly
|
||||
@@ -73,6 +90,12 @@ services:
|
||||
# host. master/volume/filer ports stay inside the compose network.
|
||||
seaweedfs:
|
||||
image: chrislusf/seaweedfs:3.80@sha256:1055999e08eed1789b0ae45d235126e4495e23d3fb9d6396293fd42539b1ae6a
|
||||
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
command:
|
||||
- server
|
||||
- -s3
|
||||
@@ -106,13 +129,21 @@ services:
|
||||
# the broker; PostgreSQL's outbox remains the source of truth for intent.
|
||||
broker:
|
||||
image: rabbitmq:4.3.7-management-alpine@sha256:1528a88eebf2bc4d0ab7e9d5d9bc542e9bdf5e1b105e65848fcf8de5c2186528
|
||||
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
hostname: broker
|
||||
networks: [default, observability]
|
||||
environment:
|
||||
RABBITMQ_DEFAULT_USER: ${BROKER_USER:-messenger}
|
||||
RABBITMQ_DEFAULT_PASS: ${BROKER_PASSWORD:-messenger}
|
||||
RABBITMQ_DEFAULT_VHOST: ${BROKER_VHOST:-messenger}
|
||||
volumes:
|
||||
- rabbitmq-data:/var/lib/rabbitmq
|
||||
- ./infra/rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro
|
||||
ports:
|
||||
# Management UI only on loopback, for operator evidence. AMQP stays internal.
|
||||
- "127.0.0.1:${BROKER_MANAGEMENT_PORT:-15672}:15672"
|
||||
@@ -180,6 +211,8 @@ services:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
VERSION: ${VERSION:-dev}
|
||||
# Общий сетевой alias: LB резолвит одно имя в адреса всех реплик, поэтому
|
||||
# масштабирование и замена контейнеров не зависят от их номеров/ID.
|
||||
networks:
|
||||
@@ -192,6 +225,13 @@ services:
|
||||
# Explicit values win over localhost defaults coming from .env (see .env.example).
|
||||
environment:
|
||||
APP_CONFIG: /etc/messenger/dev/config.yaml
|
||||
OTEL_SERVICE_NAME: messenger-api
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://otel-collector:4318}
|
||||
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
|
||||
OTEL_RESOURCE_ATTRIBUTES: deployment.environment.name=lab
|
||||
OTEL_METRIC_EXPORT_INTERVAL: ${OTEL_METRIC_EXPORT_INTERVAL:-15000}
|
||||
TELEMETRY_ENABLED: ${TELEMETRY_ENABLED:-1}
|
||||
GOMEMLIMIT: ${API_GOMEMLIMIT:-192MiB}
|
||||
POSTGRES_HOST: postgres
|
||||
POSTGRES_PORT: "5432"
|
||||
POSTGRES_DATABASE: ${POSTGRES_DB:-messenger}
|
||||
@@ -271,6 +311,13 @@ services:
|
||||
required: false
|
||||
environment:
|
||||
APP_CONFIG: /etc/messenger/dev/config.yaml
|
||||
OTEL_SERVICE_NAME: messenger-worker
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://otel-collector:4318}
|
||||
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
|
||||
OTEL_RESOURCE_ATTRIBUTES: deployment.environment.name=lab
|
||||
OTEL_METRIC_EXPORT_INTERVAL: ${OTEL_METRIC_EXPORT_INTERVAL:-15000}
|
||||
TELEMETRY_ENABLED: ${TELEMETRY_ENABLED:-1}
|
||||
GOMEMLIMIT: ${WORKER_GOMEMLIMIT:-768MiB}
|
||||
POSTGRES_HOST: postgres
|
||||
POSTGRES_PORT: "5432"
|
||||
POSTGRES_DATABASE: ${POSTGRES_DB:-messenger}
|
||||
@@ -341,6 +388,13 @@ services:
|
||||
required: false
|
||||
environment:
|
||||
APP_CONFIG: /etc/messenger/dev/config.yaml
|
||||
OTEL_SERVICE_NAME: messenger-relay
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: ${OTEL_EXPORTER_OTLP_ENDPOINT:-http://otel-collector:4318}
|
||||
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
|
||||
OTEL_RESOURCE_ATTRIBUTES: deployment.environment.name=lab
|
||||
OTEL_METRIC_EXPORT_INTERVAL: ${OTEL_METRIC_EXPORT_INTERVAL:-15000}
|
||||
TELEMETRY_ENABLED: ${TELEMETRY_ENABLED:-1}
|
||||
GOMEMLIMIT: ${RELAY_GOMEMLIMIT:-96MiB}
|
||||
POSTGRES_HOST: postgres
|
||||
POSTGRES_PORT: "5432"
|
||||
POSTGRES_DATABASE: ${POSTGRES_DB:-messenger}
|
||||
@@ -387,6 +441,13 @@ services:
|
||||
# rotation entirely; infra/lb/haproxy.cfg holds the upstream, checks and retries.
|
||||
lb:
|
||||
image: haproxy:3.2-alpine@sha256:254e6370f01cd654e0744edf607c67f33777c1b6a9dc0d4b28bcba7171460122
|
||||
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
networks: [default, observability]
|
||||
volumes:
|
||||
- ./infra/lb/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
ports:
|
||||
@@ -403,8 +464,169 @@ services:
|
||||
memory: 48M
|
||||
restart: unless-stopped
|
||||
|
||||
# --- Lab6 telemetry profile ------------------------------------------------
|
||||
# Start with: docker compose --profile telemetry up -d --build
|
||||
otel-collector:
|
||||
# The manifest-list digest resolves to linux/386 on this Docker Desktop;
|
||||
# pin the arm64 child digest and keep the platform explicit. On amd64 set
|
||||
# OTEL_COLLECTOR_IMAGE/PLATFORM to the amd64 child digest.
|
||||
image: ${OTEL_COLLECTOR_IMAGE:-otel/opentelemetry-collector-contrib:0.164.0@sha256:340c9ca6a36617084c6661bdc4f0fe92b7cda5a805d61673ec8db375fddc522b}
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
environment:
|
||||
GOMEMLIMIT: 140MiB
|
||||
profiles: [telemetry]
|
||||
command: ["--config=/etc/otel/collector.yaml"]
|
||||
volumes:
|
||||
- ./infra/otel/collector.yaml:/etc/otel/collector.yaml:ro
|
||||
networks: [default, observability]
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "${OTEL_COLLECTOR_CPU_LIMIT:-0.25}"
|
||||
memory: ${OTEL_COLLECTOR_MEM_LIMIT:-192M}
|
||||
restart: unless-stopped
|
||||
|
||||
prometheus:
|
||||
image: ${PROMETHEUS_IMAGE:-prom/prometheus:v3.15.1@sha256:fa3302279710be2f21a8301ec17a8b4f2301fd829bd113839b3b6b02b6f191a2}
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
environment:
|
||||
GOMEMLIMIT: 256MiB
|
||||
profiles: [telemetry]
|
||||
command:
|
||||
- --config.file=/etc/prometheus/prometheus.yml
|
||||
- --storage.tsdb.path=/prometheus
|
||||
- --storage.tsdb.retention.time=7d
|
||||
- --storage.tsdb.retention.size=2GB
|
||||
- --web.enable-lifecycle
|
||||
volumes:
|
||||
- ./infra/prometheus:/etc/prometheus:ro
|
||||
- prometheus-data:/prometheus
|
||||
ports:
|
||||
- "127.0.0.1:${PROMETHEUS_PORT:-9090}:9090"
|
||||
networks: [observability]
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "${PROMETHEUS_CPU_LIMIT:-0.50}"
|
||||
memory: ${PROMETHEUS_MEM_LIMIT:-320M}
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:9090/-/healthy >/dev/null || exit 1"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 12
|
||||
start_period: 10s
|
||||
restart: unless-stopped
|
||||
|
||||
loki:
|
||||
image: ${LOKI_IMAGE:-grafana/loki:3.6.4@sha256:be31579ac047e9f78b81e48f3b69d3af709e7299b431d5aa78bcda43382f9511}
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
environment:
|
||||
GOMEMLIMIT: 256MiB
|
||||
profiles: [telemetry]
|
||||
command: ["-config.file=/etc/loki/loki.yaml"]
|
||||
volumes:
|
||||
- ./infra/loki/loki.yaml:/etc/loki/loki.yaml:ro
|
||||
- loki-data:/loki
|
||||
ports:
|
||||
- "127.0.0.1:${LOKI_PORT:-3100}:3100"
|
||||
networks: [observability]
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "${LOKI_CPU_LIMIT:-0.50}"
|
||||
memory: ${LOKI_MEM_LIMIT:-320M}
|
||||
# Distroless image: no /bin/sh or wget. Readiness is checked through
|
||||
# Prometheus `up` and the /ready endpoint from the host.
|
||||
healthcheck:
|
||||
disable: true
|
||||
restart: unless-stopped
|
||||
|
||||
tempo:
|
||||
image: ${TEMPO_IMAGE:-grafana/tempo:2.9.0@sha256:65a5789759435f1ef696f1953258b9bbdb18eb571d5ce711ff812d2e128288a4}
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
environment:
|
||||
GOMEMLIMIT: 640MiB
|
||||
profiles: [telemetry]
|
||||
command: ["-config.file=/etc/tempo/tempo.yaml"]
|
||||
volumes:
|
||||
- ./infra/tempo/tempo.yaml:/etc/tempo/tempo.yaml:ro
|
||||
- tempo-data:/var/tempo
|
||||
ports:
|
||||
- "127.0.0.1:${TEMPO_PORT:-3200}:3200"
|
||||
networks: [observability]
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "${TEMPO_CPU_LIMIT:-0.25}"
|
||||
memory: ${TEMPO_MEM_LIMIT:-768M}
|
||||
# Distroless image: no /bin/sh or wget. Readiness is checked through
|
||||
# Prometheus `up` and the /ready endpoint from the host.
|
||||
healthcheck:
|
||||
disable: true
|
||||
restart: unless-stopped
|
||||
|
||||
grafana:
|
||||
image: ${GRAFANA_IMAGE:-grafana/grafana:13.2.5@sha256:9f7aa1e1e3246aade5792d35a738049f7f32f89cd51d1956cf426a4e86268a84}
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
profiles: [telemetry]
|
||||
env_file:
|
||||
- path: ./secrets/grafana.env
|
||||
required: true
|
||||
environment:
|
||||
GOMEMLIMIT: 256MiB
|
||||
GF_AUTH_ANONYMOUS_ENABLED: "false"
|
||||
GF_USERS_ALLOW_SIGN_UP: "false"
|
||||
volumes:
|
||||
- ./infra/grafana/provisioning:/etc/grafana/provisioning:ro
|
||||
- ./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro
|
||||
- grafana-data:/var/lib/grafana
|
||||
ports:
|
||||
- "127.0.0.1:${GRAFANA_PORT:-3000}:3000"
|
||||
networks: [observability]
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "${GRAFANA_CPU_LIMIT:-0.25}"
|
||||
memory: ${GRAFANA_MEM_LIMIT:-512M}
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1:3000/api/health >/dev/null || exit 1"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 12
|
||||
start_period: 10s
|
||||
restart: unless-stopped
|
||||
|
||||
networks:
|
||||
default:
|
||||
observability:
|
||||
|
||||
|
||||
volumes:
|
||||
postgres18-data:
|
||||
redis7-data:
|
||||
seaweedfs-data:
|
||||
rabbitmq-data:
|
||||
prometheus-data:
|
||||
loki-data:
|
||||
tempo-data:
|
||||
grafana-data:
|
||||
|
||||
Reference in New Issue
Block a user