|
| 1 | +# https://www.metabase.com/docs/v0.54/installation-and-operation/running-metabase-on-docker |
| 2 | + |
| 3 | +# https://www.metabase.com/docs/v0.54/installation-and-operation/running-metabase-on-docker#example-docker-compose-yaml-file |
| 4 | +services: |
| 5 | + metabase: |
| 6 | + image: metabase/metabase:v0.54.13.3 |
| 7 | + networks: |
| 8 | + - public |
| 9 | + - monitored |
| 10 | + environment: |
| 11 | + - MB_HEALTH_CHECK_LOGGING_ENABLED=false |
| 12 | + # Avoid: site URL basename "/" does not match the actual basename |
| 13 | + # https://www.metabase.com/docs/latest/configuring-metabase/environment-variables#mb_site_url |
| 14 | + - MB_SITE_URL=https://${ADMIN_DOMAIN}/metabase/ |
| 15 | + # Metabase logs: https://www.metabase.com/docs/v0.54/configuring-metabase/log-configuration |
| 16 | + - JAVA_OPTS=-Dlog4j.configurationFile=file:/etc/metabase/log4j2.xml |
| 17 | + # https://www.metabase.com/docs/v0.54/installation-and-operation/configuring-application-database |
| 18 | + - MB_DB_TYPE=postgres |
| 19 | + - MB_DB_DBNAME=metabase |
| 20 | + - MB_DB_HOST=${POSTGRES_HOST} |
| 21 | + - MB_DB_PORT=${POSTGRES_PORT} |
| 22 | + - MB_DB_USER=${METABASE_POSTGRES_USER} |
| 23 | + - MB_DB_PASS=${METABASE_POSTGRES_PASSWORD} |
| 24 | + # https://www.metabase.com/docs/v0.54/installation-and-operation/running-metabase-on-docker#setting-the-java-timezone |
| 25 | + - JAVA_TIMEZONE=UTC |
| 26 | + # https://www.metabase.com/docs/latest/installation-and-operation/observability-with-prometheus |
| 27 | + - MB_PROMETHEUS_SERVER_PORT=9191 |
| 28 | + deploy: |
| 29 | + # https://www.metabase.com/learn/metabase-basics/administration/administration-and-operation/metabase-at-scale |
| 30 | + replicas: ${METABASE_REPLICAS} |
| 31 | + update_config: |
| 32 | + parallelism: 1 |
| 33 | + order: start-first |
| 34 | + failure_action: rollback |
| 35 | + delay: 30s |
| 36 | + placement: |
| 37 | + constraints: |
| 38 | + - node.labels.ops==true |
| 39 | + labels: |
| 40 | + # prometheus only keeps jobs with `prometheus-job` label |
| 41 | + - prometheus-job=metabase |
| 42 | + # Set in `MB_PROMETHEUS_SERVER_PORT` environment variable |
| 43 | + - prometheus-port=9191 |
| 44 | + # TODO: add prometheus metrics |
| 45 | + - traefik.enable=true |
| 46 | + - traefik.docker.network=${PUBLIC_NETWORK} |
| 47 | + # router |
| 48 | + - traefik.http.routers.metabase.rule=Host(`${ADMIN_DOMAIN}`) && PathPrefix(`/metabase`) |
| 49 | + - traefik.http.routers.metabase.entrypoints=https |
| 50 | + - traefik.http.routers.metabase.tls=true |
| 51 | + - traefik.http.middlewares.metabase_stripprefixregex.stripprefixregex.regex=^/metabase |
| 52 | + - traefik.http.routers.metabase.middlewares=ops_whitelist_ips@swarm, ops_gzip@swarm, ops_auth@swarm, metabase_stripprefixregex |
| 53 | + # service |
| 54 | + - traefik.http.services.metabase.loadbalancer.server.port=3000 |
| 55 | + - traefik.http.services.metabase.loadbalancer.healthcheck.path=/api/health |
| 56 | + - traefik.http.services.metabase.loadbalancer.healthcheck.interval=10s |
| 57 | + # GET method sometimes fails (`Request canceled before finishing`) log |
| 58 | + # This does not happen with HEAD method. Official healthcheck documentation |
| 59 | + # defines HEAD as well |
| 60 | + - traefik.http.services.metabase.loadbalancer.healthcheck.method=HEAD |
| 61 | + - traefik.http.services.metabase.loadbalancer.healthcheck.timeout=1s |
| 62 | + |
| 63 | + # https://www.metabase.com/learn/metabase-basics/administration/administration-and-operation/metabase-in-production |
| 64 | + resources: |
| 65 | + limits: |
| 66 | + memory: 2G |
| 67 | + cpus: "2.0" |
| 68 | + reservations: |
| 69 | + memory: 1G |
| 70 | + cpus: "1.0" |
| 71 | + healthcheck: |
| 72 | + test: curl --fail -I http://localhost:3000/api/health || exit 1 |
| 73 | + interval: 15s |
| 74 | + timeout: 5s |
| 75 | + retries: 5 |
| 76 | + configs: |
| 77 | + - source: logging_configuration |
| 78 | + target: /etc/metabase/log4j2.xml |
| 79 | + |
| 80 | +configs: |
| 81 | + logging_configuration: |
| 82 | + file: ./logging_configuration.xml |
| 83 | + name: {{ STACK_NAME }}_logging_configuration_{{ "./logging_configuration.xml" | sha256file | substring(0,10) }} |
| 84 | + |
| 85 | +networks: |
| 86 | + public: |
| 87 | + external: true |
| 88 | + name: ${PUBLIC_NETWORK} |
| 89 | + monitored: |
| 90 | + name: ${MONITORED_NETWORK} |
| 91 | + external: true |
0 commit comments