Building Metabase

This doc will show you how you can build and run Metabase on your own computer so you can play around with it or test features in development. You can also run development branches of Metabase using a pre-built Docker image.

Install the prerequisites

If you’re using macOS, you’ll want to install Xcode Command Line Tools first, by running

xcode-select --install

To complete any build of the Metabase code, you’ll need to install the following.

  1. Clojure (https://clojure.dev.org.tw) - install the latest release by following the guide depending on your OS

  2. Java Development Kit JDK (https://adoptopenjdk.net/releases.html) - you need to install JDK 11 (more info on Java versions)

  3. Node.js (https://node.dev.org.tw/) - latest LTS release

  4. Yarn package manager for Node.js - latest release of version 1.x - you can install it in any OS by running

npm install --global yarn

On a most recent stable Ubuntu/Debian, all the tools above, with the exception of Clojure, can be installed by using

sudo apt install openjdk-11-jdk nodejs && sudo npm install --global yarn

If you have multiple JDK versions installed in your machine, be sure to switch your JDK before building with

sudo update-alternatives --config java

Then select Java 21 in the menu.

Running on M1 Apple computers

If you are developing on newer Apple M1 computers, please note that the current NodeJS LTS has native support for arm architecture. However, make sure you have Rosetta 2 installed before you attempt to build the frontend

/usr/sbin/softwareupdate --install-rosetta (root permission not required)

or

/usr/sbin/softwareupdate --install-rosetta --agree-to-license (root permission required)

If you’re running Windows, use WSL

If you are developing on Windows, you should run Ubuntu on Windows Subsystem for Linux (WSL) and follow instructions for Ubuntu/Linux.

Developing with VS Code in a remote container

Alternatively, without the need to explicitly install the above dependencies, follow the guide on using Visual Studio Code and its remote container support.

Clone the Metabase repo

Once you’ve installed all the build tools, you’ll need to clone the Metabase repository from GitHub.

  1. Create a workspace folder (you can name it that or whatever you want), which will store the Metabase code files.

  2. Open up your terminal app, and navigate to your workspace folder with

cd ~/workspace

{:start=”3”} 3. Run the following command to “clone” Metabase into this folder, using the URL of the Metabase repository on GitHub

git clone https://github.com/metabase/metabase

Choose the branch you want to run, and run it

This is the part that you’ll use over and over.

The “official” branch of Metabase is called master, and other feature development branches get merged into it when they’re approved. So if you want to try out a feature before then, you’ll need to know the name of that branch so you can switch over to it. Here’s what to do

{:start=”4”} 4. Open up your terminal app

  1. Navigate to where you’re storing the Metabase code. If you followed this guide exactly, you’d get there by entering this command

    cd ~/workspace/metabase
    
  2. “Pull” down the latest code by running

    git pull
    

    You should do this every time to make sure that you have all the latest Metabase branches and code on your computer. It’s also how you’ll get updates on a feature branch someone make changes to it.

  3. Find the name of the branch you want to run by going to the “pull request” page for that feature on GitHub and copying the branch name from there. Here’s an example PR page, with the branch name fix-native-dataset-drill-popover.

  4. Switch to, or “check out,” that branch by running

    git checkout <branch-name>
    

    If we wanted to switch to the branch in the previous step, we’d run

    git checkout fix-native-dataset-drill-popover
    

    When you want to switch back to master, run

    git checkout master
    

Run Metabase

{:start=”9”} 9. Now we’ll start up the backend server of Metabase with

clojure -M:run

When it’s done, you should see a message that says something like “Metabase initialization complete.” Keep this tab in your terminal app running, otherwise it’ll stop Metabase.

  1. Open up another tab or window of your terminal app, and then “build” the frontend (all the UI) with this command
yarn build-hot

If you’re having trouble with this step, make sure you are using the LTS version of Node.js (https://node.dev.org.tw/).

{:start=”11”} 11. In your web browser of choice, navigate to https://127.0.0.1:3000, where you should see Metabase!

這是您電腦上的本機「伺服器」,而 3000 則是 Metabase 運行的「埠號」。您的電腦上可以有多個不同的應用程式在不同的埠號上運行。請注意,如果您與其他人分享任何以 localhost 開頭的網址,他們將無法存取,因為基於安全考量,您的電腦預設不對外開放。

若要切換到不同的分支或返回 master,請開啟另一個終端機視窗,並重複步驟 6、7 和 8。如果 Metabase 尚未運行,您也需要再次完成步驟 9 和 10。如果它已經在運行,前端將會自動重建。您可以切換到終端機中的該視窗來查看進度 — 通常大約需要 15 秒,但會根據您的硬體而有所不同。

關閉 Metabase

如果您想停止 Metabase 運行,您可以結束您的終端機程式,或者前往後端運行的視窗並按下 Ctrl+C 來停止後端。大多數時候您不需要這樣做來切換分支,但在某些情況下,您嘗試查看的變更或功能是後端的變更,您可能需要使用 Ctrl+C 停止後端,然後再次完成步驟 9 來重新啟動它。

建置 Metabase Uberjar

整個 Metabase 應用程式會被編譯並組裝成單個 .jar 檔案,該檔案可以在任何現代 JVM 上運行。有一個腳本可以執行此過程中的所有步驟,並為您輸出最終成品。您可以在運行建置腳本之前傳遞環境變數 MB_EDITION,以選擇您要建置的版本。如果您不提供值,預設值為 oss,這將建置社群版。

./bin/build.sh

運行建置腳本後,只需在 target/uberjar 中尋找輸出的 .jar 檔案,您就可以開始使用了。

在容器化環境中建置 Metabase Uberjar

如果您想在不於您的主機上安裝 Clojure、Java 和 Node.js 的情況下建置 Metabase,您可以在容器內建置 Uberjar,方法是運行

DOCKER_BUILDKIT=1 docker build --output container-output/ .

請確保您的 Docker Daemon 在執行命令之前正在運行。運行命令後,您會在 ./container-output/app/metabase.jar 找到 Metabase JAR 檔案。

閱讀其他版本的 Metabase 文件