Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

1.5 KB
Raw Blame
services:
  postgres:
    image: metabase/qa-databases:postgres-sample-15
    environment:
      POSTGRES_USER: metabase
      POSTGRES_PASSWORD: metabase
      # The image ships /docker-entrypoint-initdb.d/sample_data.sql.gz, which the
      # entrypoint loads into POSTGRES_DB on first boot. Keep this as `sample` so
      # the test data lands in its own database instead of the app db.
      POSTGRES_DB: sample
    healthcheck:
      # Only succeeds once the real server starts which means that 00-create-app-db.sql 
      # and sample_data.sql.gz have finished (a temp server exists during initialization).
      test: ["CMD-SHELL", "pg_isready -U metabase -h 127.0.0.1"]
      interval: 5s
      timeout: 5s
      retries: 5
      # Grace period where retries aren't counted while everything initializes
      start_period: 60s
    volumes:
      # QA image sets PGDATA=/data
      - postgres_data:/data
      # Runs before sample_data.sql.gz (initdb.d files run in alphabetical order)
      # and creates the `metabase` app db alongside the `sample` data db.
      - ./init/00-create-app-db.sql:/docker-entrypoint-initdb.d/00-create-app-db.sql:ro

  metabase:
    image: ${METABASE_IMAGE:-metabase/metabase:latest}
    ports:
      - "127.0.0.1:${METABASE_PORT:-3000}:3000"
    environment:
      MB_DB_TYPE: postgres
      MB_DB_DBNAME: metabase
      MB_DB_PORT: 5432
      MB_DB_USER: metabase
      MB_DB_PASS: metabase
      MB_DB_HOST: postgres
    depends_on:
      postgres:
        condition: service_healthy

volumes:
  postgres_data: