237 lines
6.6 KiB
YAML
237 lines
6.6 KiB
YAML
name: mtusi-lab6
|
|
|
|
x-app-env: &app-env
|
|
DATABASE_URL: postgresql://messenger:${POSTGRES_PASSWORD}@postgres:5432/messenger
|
|
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
|
IDEMPOTENCY_TTL_SECONDS: ${IDEMPOTENCY_TTL_SECONDS:-86400}
|
|
S3_ENDPOINT: http://s3:8333
|
|
S3_REGION: us-east-1
|
|
S3_BUCKET: messenger-attachments
|
|
S3_ACCESS_KEY_ID: ${S3_ACCESS_KEY}
|
|
S3_SECRET_ACCESS_KEY: ${S3_SECRET_KEY}
|
|
BROKER_URL: amqp://${RABBITMQ_USER}:${RABBITMQ_PASSWORD}@rabbitmq:5672/%2F
|
|
RABBITMQ_MANAGEMENT_URL: http://rabbitmq:15672
|
|
WORKER_CONCURRENCY: ${WORKER_CONCURRENCY:-2}
|
|
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5}
|
|
JOB_TIMEOUT_SECONDS: ${JOB_TIMEOUT_SECONDS:-60}
|
|
STAGING_RETENTION_SECONDS: ${STAGING_RETENTION_SECONDS:-86400}
|
|
MAX_UPLOAD_BYTES: "10485760"
|
|
MAX_IMAGE_PIXELS: "40000000"
|
|
DB_POOL_MAX: "8"
|
|
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
|
|
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
|
|
SERVICE_VERSION: "1.6.0"
|
|
FAULT_DIR: /faults
|
|
AWS_EC2_METADATA_DISABLED: "true"
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:16.6-alpine
|
|
environment:
|
|
POSTGRES_USER: messenger
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
|
POSTGRES_DB: messenger
|
|
volumes:
|
|
- pg-data:/var/lib/postgresql/data
|
|
- ./app/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql:ro
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
start_period: 10s
|
|
mem_limit: 512m
|
|
restart: unless-stopped
|
|
|
|
s3:
|
|
image: chrislusf/seaweedfs:4.51
|
|
command: ["server", "-dir=/data", "-ip=0.0.0.0", "-ip.bind=0.0.0.0", "-s3", "-s3.port=8333", "-s3.ip.bind=0.0.0.0", "-s3.config=/etc/seaweed/s3.json"]
|
|
volumes:
|
|
- s3-data:/data
|
|
- ./infra/seaweed/s3.json:/etc/seaweed/s3.json:ro
|
|
healthcheck:
|
|
test: ["CMD", "weed", "version"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 20
|
|
start_period: 5s
|
|
mem_limit: 512m
|
|
restart: unless-stopped
|
|
|
|
rabbitmq:
|
|
image: rabbitmq:3.13.7-management-alpine
|
|
environment:
|
|
RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER}
|
|
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD}
|
|
volumes:
|
|
- rabbit-data:/var/lib/rabbitmq
|
|
healthcheck:
|
|
test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 20
|
|
start_period: 15s
|
|
mem_limit: 512m
|
|
restart: unless-stopped
|
|
|
|
api-1: &api
|
|
build: .
|
|
image: mtusi-lab6-messenger:1.6.0
|
|
environment:
|
|
<<: *app-env
|
|
OTEL_SERVICE_NAME: messenger-api
|
|
INSTANCE_ID: api-1
|
|
APP_ROLE: api
|
|
OTEL_RESOURCE_ATTRIBUTES: deployment.environment.name=lab,service.version=1.6.0,service.instance.id=api-1
|
|
volumes:
|
|
- ./faults:/faults
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
rabbitmq:
|
|
condition: service_healthy
|
|
s3:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=3)"]
|
|
interval: 5s
|
|
timeout: 4s
|
|
retries: 30
|
|
start_period: 20s
|
|
mem_limit: 512m
|
|
restart: unless-stopped
|
|
|
|
api-2:
|
|
<<: *api
|
|
environment:
|
|
<<: *app-env
|
|
OTEL_SERVICE_NAME: messenger-api
|
|
INSTANCE_ID: api-2
|
|
APP_ROLE: api
|
|
OTEL_RESOURCE_ATTRIBUTES: deployment.environment.name=lab,service.version=1.6.0,service.instance.id=api-2
|
|
|
|
worker:
|
|
build: .
|
|
image: mtusi-lab6-messenger:1.6.0
|
|
command: ["python", "-m", "app.worker"]
|
|
environment:
|
|
<<: *app-env
|
|
OTEL_SERVICE_NAME: messenger-worker
|
|
INSTANCE_ID: worker-1
|
|
APP_ROLE: worker
|
|
OTEL_RESOURCE_ATTRIBUTES: deployment.environment.name=lab,service.version=1.6.0,service.instance.id=worker-1
|
|
volumes:
|
|
- ./faults:/faults
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
rabbitmq:
|
|
condition: service_healthy
|
|
s3:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8081/health/ready', timeout=3)"]
|
|
interval: 5s
|
|
timeout: 4s
|
|
retries: 30
|
|
start_period: 20s
|
|
mem_limit: 512m
|
|
restart: unless-stopped
|
|
|
|
nginx:
|
|
image: nginx:1.27.4-alpine
|
|
depends_on:
|
|
api-1:
|
|
condition: service_healthy
|
|
api-2:
|
|
condition: service_healthy
|
|
ports:
|
|
- "127.0.0.1:8080:80"
|
|
volumes:
|
|
- ./infra/nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
|
mem_limit: 128m
|
|
restart: unless-stopped
|
|
|
|
otel-collector:
|
|
image: otel/opentelemetry-collector-contrib:0.120.0
|
|
command: ["--config=/etc/otelcol/collector.yaml"]
|
|
volumes:
|
|
- ./infra/otel/collector.yaml:/etc/otelcol/collector.yaml:ro
|
|
depends_on:
|
|
- tempo
|
|
- loki
|
|
- prometheus
|
|
mem_limit: 320m
|
|
restart: unless-stopped
|
|
|
|
prometheus:
|
|
image: prom/prometheus:v2.55.1
|
|
command:
|
|
- --config.file=/etc/prometheus/prometheus.yml
|
|
- --storage.tsdb.path=/prometheus
|
|
- --storage.tsdb.retention.time=2d
|
|
- --web.enable-lifecycle
|
|
volumes:
|
|
- ./infra/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
|
- ./infra/prometheus/rules.yml:/etc/prometheus/rules.yml:ro
|
|
- prometheus-data:/prometheus
|
|
ports:
|
|
- "127.0.0.1:9090:9090"
|
|
mem_limit: 512m
|
|
restart: unless-stopped
|
|
|
|
loki:
|
|
image: grafana/loki:3.3.2
|
|
command: ["-config.file=/etc/loki/loki.yml"]
|
|
volumes:
|
|
- ./infra/loki/loki.yml:/etc/loki/loki.yml:ro
|
|
- loki-data:/loki
|
|
ports:
|
|
- "127.0.0.1:3100:3100"
|
|
mem_limit: 512m
|
|
restart: unless-stopped
|
|
|
|
tempo:
|
|
image: grafana/tempo:2.7.2
|
|
command: ["-config.file=/etc/tempo/tempo.yml"]
|
|
volumes:
|
|
- ./infra/tempo/tempo.yml:/etc/tempo/tempo.yml:ro
|
|
- tempo-data:/var/tempo
|
|
ports:
|
|
- "127.0.0.1:3200:3200"
|
|
mem_limit: 512m
|
|
restart: unless-stopped
|
|
|
|
grafana:
|
|
image: grafana/grafana:11.5.2
|
|
environment:
|
|
GF_SECURITY_ADMIN_USER: admin
|
|
GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD}
|
|
GF_AUTH_ANONYMOUS_ENABLED: "true"
|
|
GF_AUTH_ANONYMOUS_ORG_ROLE: Viewer
|
|
GF_USERS_ALLOW_SIGN_UP: "false"
|
|
GF_ANALYTICS_REPORTING_ENABLED: "false"
|
|
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
|
|
GF_SERVER_HTTP_PORT: "3000"
|
|
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:3000:3000"
|
|
depends_on:
|
|
- prometheus
|
|
- loki
|
|
- tempo
|
|
mem_limit: 384m
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
pg-data:
|
|
s3-data:
|
|
rabbit-data:
|
|
prometheus-data:
|
|
loki-data:
|
|
tempo-data:
|
|
grafana-data:
|