Skip to content

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

7.9 KB
Raw Blame
version: '3.1'

# A useful compose file for local development.
# This compose file contains preconfigured services for many common development
# tasks. The local-dev and *-app-db services will stand up an instance of
# metabase and a corresponding app-db. The *-data services are sample QA images
# that can be used as warehouses.
#
# Examples: Which services you run are configured by profiles and can be run as
#  shown in the following examples:
#
# ;; Run a postgres app db and a sample postgres 14 and mongo warehouses
# COMPOSE_PROFILES=postgresappdb,postgres14data,mongodata docker-compose --file dev/docker-compose.yml up
# ;; Run a postgres app db and a sample postgres 14 and mysql 5.7 warehouses
# COMPOSE_PROFILES=postgresappdb,postgres14data,mysql57data docker-compose --file dev/docker-compose.yml up
# ;; Run a postgres app db, a sample postgres 14 and mysql 5.7 warehouses, and metabase itself in a container
# ;; If you use this option, once the application starts you can jack in on 50505 and REPL away.
# ;; Be aware that if you use this option your app will be running a docker
# ;; network with ports 3001 and 50505 exposed to the outside. This means that
# ;; when you connect to data warehouses, you'll use docker networking to
# ;; connect (e.g. metabasedb_postgres_14_data:5432 vs. localhost:15432).
# COMPOSE_PROFILES=postgresappdb,postgres14data,mysql57data,dev-app docker-compose --file dev/docker-compose.yml up
# ;; All of the above, and builds the frontend, too. No need for `bun run build-hot` locally.
# COMPOSE_PROFILES=postgresappdb,postgres14data,mysql57data,fe-builder,dev-app docker-compose --file dev/docker-compose.yml up
#
# TODOs:
# - Consider using swarm to declaratively scale up/down.
services:

  # The local-dev profile enables development against a metabase instance.
  # This does the following:
  # - Launch metabase in a clojure container with the most common dev profiles enabled
  # - Expose 3001 for local access to metabase
  # - Expose 50505 for socket repl jack-in
  # Note that the default config is for a postgres backend. You can set the
  # environment differently (see https://docs.docker.com/compose/environment-variables/set-environment-variables/)
  # for other backends (e.g. MySQL).
  local-dev:
    image: clojure
    container_name: metabase-app
    ports:
      - "127.0.0.1:3001:3000"
      - "127.0.0.1:50505:50505"
    working_dir: /dev/metabase
    volumes:
      - ../:/dev/metabase
      - ~/.m2:/root/.m2
    environment:
      MB_API_KEY: METABASE
      MB_DB_CONNECTION_URI: "${MB_DB_CONNECTION_URI:-jdbc:postgresql://metabase-postgres-app-db:5432/metabase?user=mbuser&password=password}"
      MB_DB_HOST: "${MB_DB_HOST:-metabase-postgres-app-db}"
      MB_DB_PORT: "${MB_DB_PORT:-5432}"
      MB_MYSQL_TEST_USER: root
      MB_MYSQL_TEST_PASSWORD: metasample123
      MB_MYSQL_TEST_HOST: metabasedb_mysql_5_7_data
      MB_MYSQL_TEST_PORT: 3306
      MB_POSTGRESQL_TEST_DB: clean
      MB_POSTGRESQL_TEST_PASSWORD: password
      MB_POSTGRESQL_TEST_PORT: 5432
      MB_POSTGRESQL_TEST_USER: user
    # The :socket alias binds the REPL to loopback inside the container, which docker's port
    # forwarding can't reach, so bind it to all container interfaces here instead. The host
    # side stays loopback-only via the 127.0.0.1: prefix in `ports` above.
    command: ["clojure", "-J-Dclojure.server.repl={:address,\"0.0.0.0\",:port,50505,:accept,clojure.core.server/repl}", "-M:run:dev:drivers:drivers-dev:ee:ee-dev"]
    profiles:
      - dev-app
    networks:
      - metabasenet

  # Builds the frontend with hot reload. Mounts local dev so nothing else
  # needed.
  fe-builder:
    # Reuses the repo's devcontainer image (JDK + Node + Bun + Clojure
    # CLI) so the FE/CLJS toolchain is maintained in exactly one place.
    build:
      context: ../.devcontainer
      dockerfile: Dockerfile
    container_name: fe-builder
    working_dir: /dev/metabase
    # In hot mode rspack inlines an absolute publicPath of
    # http://localhost:8080/ into index.html (see rspack.main.config.js), so
    # the browser loads the bundle from the host's :8080 — it must be
    # published, not just exposed on the docker network.
    ports:
      - "127.0.0.1:8080:8080"
    volumes:
      - ../:/dev/metabase
      - ~/.bun/install/cache:/root/.bun/install/cache
    environment:
      # rspack binds to loopback by default; inside the container it must listen on all
      # interfaces for docker's port forwarding to reach it.
      MB_FRONTEND_DEV_HOST: 0.0.0.0
    command:
      - /bin/sh
      - -c
      - |
        bun install
        bun run build-hot
    profiles:
      - fe-builder

  # App dbs. You only need one. If running metabase containerized, use the
  # corresponding service.
  metabase-postgres-app-db:
    image: postgres
    container_name: metabase-postgres-app-db
    restart: always
    ports:
      - "127.0.0.1:5432:5432"
    environment:
      POSTGRES_USER: mbuser
      POSTGRES_PASSWORD: password
      POSTGRES_DB: metabase
    profiles:
      - postgresappdb
    networks:
      - metabasenet

  # If using the mysql app db, be sure to set the environment correctly for the
  # metabase app, whether running the app containerized or locally
  metabase-mysql-5.7-app-db:
    image: mysql:5.7
    container_name: metabase-mysql57-app-db
    restart: always
    ports:
      - "127.0.0.1:3306:3306"
    environment:
      MYSQL_USER: mbuser
      MYSQL_PASSWORD: password
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: metabase
    profiles:
      - mysql57appdb
    networks:
      - metabasenet

  # The following *-data instances are sample warehouse dbs that can be found at
  # https://hub.docker.com/r/metabase/qa-databases/tags.
  # For reference, these are the env vars used for these that might be useful
  # when configuring your app db.
  # ENV MYSQL_DATABASE=sample
  # ENV MYSQL_USER=metabase
  # ENV MYSQL_PASSWORD=metasample123
  postgres-sample-14-data:
    image: metabase/qa-databases:postgres-sample-14
    container_name: metabasedb_postgres_14_data
    ports:
      - "127.0.0.1:15432:5432"
    restart: always
    profiles:
      - postgres14data
    networks:
      - metabasenet

  mysql-sample-5.7-data:
    image: metabase/qa-databases:mysql-sample-5.7
    container_name: metabasedb_mysql_5_7_data
    ports:
      - "127.0.0.1:23306:3306"
    restart: always
    profiles:
      - mysql57data
    networks:
      - metabasenet

  mysql-sample-8-data:
    image: metabase/qa-databases:mysql-sample-8
    container_name: metabasedb_mysql_8_data
    ports:
      - "127.0.0.1:13306:3306"
    restart: always
    profiles:
      - mysql8data
    networks:
      - metabasenet

  mongo-data:
    image: metabase/qa-databases:mongo-sample-6
    container_name: metabasedb_mongo_6_data
    restart: always
    ports:
      - "127.0.0.1:27017:27017"
    profiles:
      - mongodata
    networks:
      - metabasenet

  vertica-data:
    image: vertica/vertica-ce:12.0.2-0
    container_name: vertica_data
    restart: always
    ports:
      - "127.0.0.1:5433:5433"
    profiles:
      - verticadata
    networks:
      - metabasenet


  # Used this if you need to test metabase's email capabilities
  maildev:
    image: maildev/maildev:latest
    container_name: maildev
    ports:
      - "127.0.0.1:1080:1080"
      - "127.0.0.1:1025:1025"
    profiles:
      - pulse
    networks:
      - metabasenet

  # Used for testing with SAML
  saml:
    build: https://github.com/mcguinness/saml-idp.git
    volumes:
      - ./idp-private-key.pem:/idp-private-key.pem
      - ./idp-public-cert.pem:/idp-public-cert.pem
    ports:
      - "127.0.0.1:7000:7000"
    entrypoint:
      - node
      - app.js
      - --host
      - "0.0.0.0"
      - --port
      - "7000"
      - --acs
      - https://foo.okta.com/auth/saml20/example
      - --aud
      - https://www.okta.com/saml2/service-provider/spf5aFRRXFGIMAYXQPNV"
    profiles:
      - sso
    networks:
      - metabasenet

networks:
  metabasenet: