Deploying a Lightdash App
Introduction
Lightdash is an open-source BI and metrics layer that sits on top of dbt. Deploying Lightdash with a Dockerfile on Klutch.sh gives you reproducible builds, managed secrets, and persistent storage for cached assets—all configured from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, sample usage, and production tips.
Prerequisites
- A Klutch.sh account (create one)
- A GitHub repository containing your Lightdash config/dbt project (GitHub is the only supported git source)
- Docker familiarity and Node.js 18+ knowledge
- Database credentials for your warehouse (e.g., Postgres, BigQuery, Snowflake)
- Optional: persistent storage for cache or logs
For platform onboarding, see the Quick Start.
Architecture and ports
- Lightdash serves HTTP; set the internal container port to
8080. - If you add Redis or other services, run them as separate Klutch.sh TCP apps exposed on port
8000and connect on native ports. - Persistent storage is optional for cache/logs; recommended if you want faster cold starts.
Repository layout
lightdash/├── Dockerfile # Must be at repo root for auto-detection├── package.json├── pnpm-lock.yaml # or yarn.lock / package-lock.json├── .env.example # Template only; no secrets└── README.mdKeep secrets out of Git; store them in Klutch.sh environment variables.
Installation (local) and starter commands
Install dependencies and run locally before pushing to GitHub:
pnpm installpnpm buildpnpm start -- --port 8080Optional helper start.sh for portability and Nixpacks fallback:
#!/usr/bin/env bashset -euo pipefailpnpm start -- --port 8080Make it executable with chmod +x start.sh.
Dockerfile for Lightdash (production-ready)
Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker selection in the UI):
FROM node:18-alpine AS buildWORKDIR /app
COPY package.json pnpm-lock.yaml* yarn.lock* package-lock.json* ./RUN corepack enableRUN pnpm install --frozen-lockfile
COPY . .RUN pnpm build
FROM node:18-alpineWORKDIR /appENV NODE_ENV=production PORT=8080
COPY --from=build /app /appRUN corepack enable && pnpm install --prod --frozen-lockfile
EXPOSE 8080CMD ["pnpm", "start", "--", "--port", "8080"]Notes:
- Add build tools (
apk add --no-cache python3 make g++) in the build stage if native modules are required. - Ensure your dbt profiles and warehouse credentials are provided via environment variables or secrets.
Environment variables (Klutch.sh)
Set these in the Klutch.sh app settings (Secrets tab) before deploying:
NODE_ENV=productionPORT=8080LIGHTDASH_SECRET_KEY=<secure-key>DATABASE_URL=<your-warehouse-connection-string>(or service-specific envs)DBT_PROFILES_DIR=/app/.dbt(if you include dbt profiles)LIGHTDASH_SITE_URL=https://example-app.klutch.sh
If you deploy without the Dockerfile and need Nixpacks overrides:
NIXPACKS_BUILD_CMD=pnpm install --frozen-lockfile && pnpm buildNIXPACKS_START_CMD=pnpm start -- --port 8080NIXPACKS_NODE_VERSION=18
These keep Lightdash compatible with Nixpacks defaults when a Dockerfile is absent.
Attach persistent volumes
In Klutch.sh storage settings, add mount paths and sizes (no names required):
/app/.cache— optional cache for faster rebuilds./app/logs— optional logs if you keep them on disk.
Ensure these paths are writable inside the container.
Deploy Lightdash on Klutch.sh (Dockerfile workflow)
- Push your repository (with the Dockerfile at the root) to GitHub.
- Open klutch.sh/app, create a project, and add an app.
- Connect the GitHub repository; Klutch.sh automatically detects the Dockerfile.
- Choose HTTP traffic for Lightdash.
- Set the internal port to
8080. - Add the environment variables above (secret key, database/dbt config, site URL, and any
NIXPACKS_*overrides if you temporarily deploy without the Dockerfile). - Attach persistent volumes for
/app/.cache(and/app/logsif used), selecting sizes that fit your caching/logging needs. - Deploy. Your Lightdash instance will be reachable at
https://example-app.klutch.sh; attach a custom domain if desired.
Sample API usage
Trigger a refresh of project metadata (replace placeholders):
curl -X POST "https://example-app.klutch.sh/api/v1/projects/<project-id>/refresh" \ -H "Authorization: Bearer <your-api-token>"Health checks and production tips
- Add a reverse proxy probe to
/or a lightweight status endpoint if available. - Enforce HTTPS at the edge; forward HTTP to port 8080 internally.
- Keep lockfiles committed and Node version pinned; test upgrades before applying.
- Secure your secret key and warehouse credentials in Klutch.sh secrets; rotate regularly.
- Monitor disk usage on caches/logs and resize volumes before they fill.
Lightdash on Klutch.sh combines reproducible Docker builds with managed secrets, optional persistent cache/log storage, and flexible HTTP/TCP routing. With the Dockerfile at the repo root and port 8080 configured, you can deliver reliable BI experiences without extra YAML or workflow overhead.