mattermost/server/docker-compose.yaml
Alejandro García Montoro fa7668ae0d
Some checks are pending
API / build (push) Waiting to run
Server CI / Compute Go Version (push) Waiting to run
Server CI / Check mocks (push) Blocked by required conditions
Server CI / Check go mod tidy (push) Blocked by required conditions
Server CI / check-style (push) Blocked by required conditions
Server CI / Check serialization methods for hot structs (push) Blocked by required conditions
Server CI / Vet API (push) Blocked by required conditions
Server CI / Check migration files (push) Blocked by required conditions
Server CI / Generate email templates (push) Blocked by required conditions
Server CI / Check store layers (push) Blocked by required conditions
Server CI / Check mmctl docs (push) Blocked by required conditions
Server CI / Postgres with binary parameters (push) Blocked by required conditions
Server CI / Postgres (push) Blocked by required conditions
Server CI / Postgres (FIPS) (push) Blocked by required conditions
Server CI / Generate Test Coverage (push) Blocked by required conditions
Server CI / Run mmctl tests (push) Blocked by required conditions
Server CI / Run mmctl tests (FIPS) (push) Blocked by required conditions
Server CI / Build mattermost server app (push) Blocked by required conditions
Web App CI / check-lint (push) Waiting to run
Web App CI / check-i18n (push) Blocked by required conditions
Web App CI / check-types (push) Blocked by required conditions
Web App CI / test (platform) (push) Blocked by required conditions
Web App CI / test (mattermost-redux) (push) Blocked by required conditions
Web App CI / test (channels shard 1/4) (push) Blocked by required conditions
Web App CI / test (channels shard 2/4) (push) Blocked by required conditions
Web App CI / test (channels shard 3/4) (push) Blocked by required conditions
Web App CI / test (channels shard 4/4) (push) Blocked by required conditions
Web App CI / upload-coverage (push) Blocked by required conditions
Web App CI / build (push) Blocked by required conditions
MM-67668: Replace Promtail with OpenTelemetry collector (#35381)
* Add container name to Docker logs

This will allow for querying Loki by container's name:

  {job="docker",container_name="mattermost-postgres"}

* Configue Loki to prepare for OTLP ingestion

- Add a volume to Loki container to get the config
- Configure Loki with the expected labels so that we can query by job,
  app, container.name...

* Add OpenTelemetry collector configuration

There are three pipelines:
1. logs/mattermost scrapes the logs from mattermost.log, parsing the
   timestamp and severity, and pushes them to Loki.
2. logs/docker scrapes the Docker logs from *-json.log, parsing the
   timestamp, the log itself and the container name, and pushes them to Loki.
3. metrics/docker scrapes the Docker socket to retrieve the containers'
   uptime values and pushes them to Prometheus.

* Replace Promtail with OpenTelemetry collector

* Update build tooling for OpenTelemetry collector

1. Make sure that the logs directory is created
2. Swap Promtail with OpenTelemetry collector

* Scrape collector to get Docker stats

Prometheus needs to scrape the OpenTelemetry collector in the exposed
port to get the Docker stats, so that we can query the uptime with
metric container_uptime_seconds, which has a container_name label to
filter by container.

* Update Grafana dashboard for Docker health checks

1. Use Prometheus as the datasource in all queries
2. Simplify the mappings to either 0 (offline, red) or 1 (online,
   green).
3. Unify all queries on container_uptime_seconds, filtering by
   container_name, and making sure that the latest value we got is at most
   15 seconds old, so that it does not show stale data.
4. Add Redis health check, that was missing
5. Update the dashboard title to Docker containers

* Tune Loki and OTel collector configs for local dev

- Switch filelog receivers to start_at: beginning so existing logs are
  ingested on collector startup, not just new entries.
- Fix Docker log timestamp layout to use 9s (variable-length nanos)
  instead of 0s (fixed-width), matching actual Docker JSON log format.
- Add ingester max_chunk_age to keep chunks open longer in the
  single-instance dev setup, so that we can ingest older logs (the
  window is max_chunk_age/2).
- Relax Loki limits for local development: allow unordered writes,
  disable old-sample rejection, and raise ingestion rate/burst to 64 MB
  to avoid throttling during bulk ingest.
2026-02-27 16:48:17 +01:00

248 lines
6.3 KiB
YAML

services:
postgres:
container_name: mattermost-postgres
ports:
- "5432:5432"
extends:
file: build/docker-compose.common.yml
service: postgres
minio:
container_name: mattermost-minio
ports:
- "9000:9000"
extends:
file: build/docker-compose.common.yml
service: minio
inbucket:
container_name: mattermost-inbucket
ports:
- "9001:9001"
- "10025:10025"
- "10110:10110"
extends:
file: build/docker-compose.common.yml
service: inbucket
openldap:
container_name: mattermost-openldap
ports:
- "389:389"
- "636:636"
extends:
file: build/docker-compose.common.yml
service: openldap
elasticsearch:
container_name: mattermost-elasticsearch
ports:
- "9200:9200"
- "9300:9300"
extends:
file: build/docker-compose.common.yml
service: elasticsearch
opensearch:
container_name: mattermost-opensearch
ports:
- "9201:9201"
extends:
file: build/docker-compose.common.yml
service: opensearch
redis:
container_name: mattermost-redis
ports:
- "6379:6379"
extends:
file: build/docker-compose.common.yml
service: redis
dejavu:
container_name: mattermost-dejavu
ports:
- "1358:1358"
extends:
file: build/docker-compose.common.yml
service: dejavu
keycloak:
container_name: mattermost-saml
ports:
- "8484:8080"
extends:
file: build/docker-compose.common.yml
service: keycloak
prometheus:
container_name: mattermost-prometheus
ports:
- "9090:9090"
extends:
file: build/docker-compose.common.yml
service: prometheus
grafana:
container_name: mattermost-grafana
ports:
- "3000:3000"
extends:
file: build/docker-compose.common.yml
service: grafana
loki:
container_name: mattermost-loki
ports:
- "3100:3100"
extends:
file: build/docker-compose.common.yml
service: loki
otel-collector:
container_name: mattermost-otel-collector
extends:
file: build/docker-compose.common.yml
service: otel-collector
start_dependencies:
image: mattermost/mattermost-wait-for-dep:latest
networks:
- mm-test
depends_on:
- postgres
- minio
- inbucket
- openldap
- elasticsearch
- opensearch
- prometheus
- grafana
- loki
- otel-collector
command: postgres:5432 minio:9000 inbucket:9001 openldap:389 elasticsearch:9200 opensearch:9201 prometheus:9090 grafana:3000 loki:3100 otel-collector:13133
leader:
build:
context: .
dockerfile: ./build/Dockerfile.buildenv
working_dir: '/home/mattermost-server/server'
environment:
- "MM_SQLSETTINGS_DRIVERNAME=postgres"
- "MM_SQLSETTINGS_DATASOURCE=postgres://mmuser:mostest@postgres/mattermost_test?sslmode=disable\u0026connect_timeout=10"
- "MM_NO_DOCKER=true"
- "RUN_SERVER_IN_BACKGROUND=false"
- "MM_CLUSTERSETTINGS_ENABLE=true"
- "MM_CLUSTERSETTINGS_CLUSTERNAME=mm_dev_cluster"
- "MM_LOGSETTINGS_FILELOCATION=./logs/leader"
networks:
- mm-test
depends_on:
- start_dependencies
volumes:
- './../:/home/mattermost-server'
- './../../enterprise:/home/enterprise'
restart: on-failure
healthcheck:
test: ["CMD", "curl", "-f", "http://leader:8065/api/v4/system/ping"]
interval: 5s
timeout: 30s
retries: 30
start_period: 5m
user: ${CURRENT_UID}
command: ['make', 'run-server']
expose:
- "8065"
- "8064/tcp"
- "8064/udp"
- "8074/tcp"
- "8074/udp"
- "8075"
follower:
build:
context: .
dockerfile: ./build/Dockerfile.buildenv
working_dir: '/home/mattermost-server/server'
environment:
- "MM_SQLSETTINGS_DRIVERNAME=postgres"
- "MM_SQLSETTINGS_DATASOURCE=postgres://mmuser:mostest@postgres/mattermost_test?sslmode=disable\u0026connect_timeout=10"
- "MM_NO_DOCKER=true"
- "RUN_SERVER_IN_BACKGROUND=false"
- "MM_CLUSTERSETTINGS_ENABLE=true"
- "MM_CLUSTERSETTINGS_CLUSTERNAME=mm_dev_cluster"
- "MM_LOGSETTINGS_FILELOCATION=./logs/follower"
networks:
- mm-test
depends_on:
- leader
volumes:
- './../:/home/mattermost-server:Z'
- './../../enterprise:/home/enterprise:Z'
healthcheck:
test: ["CMD", "curl", "-f", "http://follower:8065/api/v4/system/ping"]
interval: 5s
timeout: 30s
retries: 30
start_period: 5m
user: ${CURRENT_UID}
command: ['make', 'run-server']
restart: on-failure
expose:
- "8065"
- "8064/tcp"
- "8064/udp"
- "8074/tcp"
- "8074/udp"
- "8075"
follower2:
build:
context: .
dockerfile: ./build/Dockerfile.buildenv
working_dir: '/home/mattermost-server/server'
environment:
- "MM_SQLSETTINGS_DRIVERNAME=postgres"
- "MM_SQLSETTINGS_DATASOURCE=postgres://mmuser:mostest@postgres/mattermost_test?sslmode=disable\u0026connect_timeout=10"
- "MM_NO_DOCKER=true"
- "RUN_SERVER_IN_BACKGROUND=false"
- "MM_CLUSTERSETTINGS_ENABLE=true"
- "MM_CLUSTERSETTINGS_CLUSTERNAME=mm_dev_cluster"
- "MM_LOGSETTINGS_FILELOCATION=./logs/follower2"
networks:
- mm-test
depends_on:
- leader
volumes:
- './../:/home/mattermost-server:Z'
- './../../enterprise:/home/enterprise:Z'
healthcheck:
test: ["CMD", "curl", "-f", "http://follower2:8065/api/v4/system/ping"]
interval: 5s
timeout: 30s
retries: 30
start_period: 5m
user: ${CURRENT_UID}
command: ['make', 'run-server']
restart: on-failure
expose:
- "8065"
- "8064/tcp"
- "8064/udp"
- "8074/tcp"
- "8074/udp"
- "8075"
haproxy:
image: nginx
networks:
- mm-test
volumes:
- ./build/docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:Z
restart: on-failure
depends_on:
leader:
condition: service_healthy
follower:
condition: service_healthy
follower2:
condition: service_healthy
ports:
- "8065:8065"
networks:
mm-test:
driver: bridge
ipam:
driver: default
config:
- subnet: 192.168.254.0/24
ip_range: 192.168.254.0/24