Skip to content

Deploying a Metabase App

Introduction

Metabase is an open-source business intelligence and dashboarding tool built on Java and Clojure. Deploying Metabase with a Dockerfile on Klutch.sh delivers reproducible builds, managed secrets, and persistent storage for your application database—all configured from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, sample API usage, and production tips.


Prerequisites

  • A Klutch.sh account (sign up)
  • A GitHub repository containing your Dockerfile (GitHub is the only supported git source)
  • A database for Metabase application data (PostgreSQL recommended; deploy as a Klutch.sh TCP app on port 8000 and connect on 5432)
  • Domain ready for your Metabase instance

For onboarding, see the Quick Start.


Architecture and ports

  • Metabase serves HTTP on internal port 3000; choose HTTP traffic.
  • Application database is external (PostgreSQL recommended). Do not use H2 for production.
  • Persistent storage is recommended only if you run H2 (for non-production). For production, store data in Postgres.

Repository layout

metabase/
├── Dockerfile # Must be at repo root for auto-detection
└── README.md

Keep secrets out of Git; store them in Klutch.sh environment variables.


Installation (local) and starter commands

Validate locally before pushing to GitHub:

Terminal window
docker build -t metabase-local .
docker run -p 3000:3000 -e MB_DB_TYPE=postgres -e MB_DB_DBNAME=<db> -e MB_DB_PORT=5432 metabase-local

Dockerfile for Metabase (production-ready)

Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker selection in the UI):

FROM metabase/metabase:v0.46.8
ENV MB_JETTY_PORT=3000
EXPOSE 3000
CMD ["sh", "-c", "java -jar /app/metabase.jar"]

Notes:

  • Pin the image tag for stability; update intentionally.
  • Configure application DB via environment variables (see below). Avoid H2 in production.

Environment variables (Klutch.sh)

Set these in Klutch.sh before deploying:

  • MB_JETTY_PORT=3000
  • MB_DB_TYPE=postgres
  • MB_DB_DBNAME=<db-name>
  • MB_DB_HOST=<db-host>
  • MB_DB_PORT=5432
  • MB_DB_USER=<db-user>
  • MB_DB_PASS=<db-password>
  • Optional: MB_SITE_URL=https://example-app.klutch.sh
  • Optional email: MB_EMAIL_SMTP_HOST, MB_EMAIL_SMTP_PORT, MB_EMAIL_SMTP_USERNAME, MB_EMAIL_SMTP_PASSWORD, MB_EMAIL_SMTP_SECURITY=starttls

If you deploy without the Dockerfile and need Nixpacks overrides (Java):

  • NIXPACKS_JAVA_VERSION=11
  • NIXPACKS_START_CMD=java -jar /app/metabase.jar

Attach persistent volumes

In Klutch.sh storage settings, add mount paths and sizes (no names required) only if you intentionally use the built-in H2 database (non-production):

  • /metabase-data — H2 database files (not recommended for production).

For production with Postgres, volumes are optional (logs/config only if you externalize them).


Deploy Metabase on Klutch.sh (Dockerfile workflow)

  1. Push your repository—with the Dockerfile at the root—to GitHub.
  2. Open klutch.sh/app, create a project, and add an app.
  3. Select HTTP traffic and set the internal port to 3000.
  4. Add the environment variables above, pointing to your PostgreSQL database and optional SMTP settings.
  5. Attach a persistent volume only if you use H2 (non-production) at /metabase-data; otherwise skip volumes for Postgres-backed setups.
  6. Deploy. Your Metabase instance will be reachable at https://example-app.klutch.sh; attach a custom domain if desired.

Sample API usage

Create a session token:

Terminal window
curl -X POST "https://example-app.klutch.sh/api/session" \
-H "Content-Type: application/json" \
-d '{"username": "admin@example.com", "password": "<admin_password>"}'

List databases:

Terminal window
curl -X GET "https://example-app.klutch.sh/api/database" \
-H "Content-Type: application/json" \
-H "X-Metabase-Session: <session_token>"

Health checks and production tips

  • Add an HTTP probe to /api/health or / for readiness.
  • Enforce HTTPS at the edge; forward internally to port 3000.
  • Use Postgres (not H2) for production; keep DB credentials in Klutch.sh secrets and rotate them regularly.
  • Pin Metabase versions; test upgrades in staging before production.
  • Configure SMTP for password resets and notifications.

Metabase on Klutch.sh combines reproducible Docker builds with managed secrets, persistent storage options, and flexible HTTP/TCP routing. With the Dockerfile at the repo root, port 3000 configured, and Postgres connected, you can deliver secure dashboards and analytics without extra YAML or workflow overhead.