Skip to content

Deploying a Pangolin App

Introduction

Pangolin is an open-source interface for interacting with language models, featuring chats, prompt management, and API integrations. Deploying Pangolin with a Dockerfile on Klutch.sh provides reproducible builds, managed secrets, and persistent storage for uploads and logs—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 Pangolin Dockerfile (GitHub is the only supported git source)
  • Access to your LLM provider endpoint (e.g., OpenAI-compatible URL or local server)
  • Storage sizing for conversations, uploads, and logs

For onboarding, see the Quick Start.


Architecture and ports

  • Pangolin serves HTTP on internal port 3000; choose HTTP traffic.
  • Persistent storage is required for user data/uploads and optional logs.

Repository layout

pangolin/
├── 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.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
pnpm install
pnpm build
pnpm start -- --port 3000

Optional helper start.sh:

#!/usr/bin/env bash
set -euo pipefail
exec pnpm start -- --port "${PORT:-3000}"

Make it executable with chmod +x start.sh.


Dockerfile for Pangolin (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 build
WORKDIR /app
COPY package.json pnpm-lock.yaml* yarn.lock* package-lock.json* ./
RUN corepack enable
RUN pnpm install --frozen-lockfile
COPY . .
RUN pnpm build
FROM node:18-alpine
WORKDIR /app
ENV NODE_ENV=production PORT=3000
COPY --from=build /app /app
RUN corepack enable && pnpm install --prod --frozen-lockfile
EXPOSE 3000
CMD ["pnpm", "start", "--", "--port", "3000"]

Notes:

  • Add build tools (apk add --no-cache python3 make g++) if native modules are required.
  • Keep upload/log directories writable and mount them as volumes.

Environment variables (Klutch.sh)

Set these in Klutch.sh before deploying:

  • NODE_ENV=production
  • PORT=3000
  • APP_URL=https://example-app.klutch.sh
  • PROVIDER_API_URL=<llm-provider-endpoint>
  • PROVIDER_API_KEY=<llm-provider-key> (if required)
  • Optional: UPLOAD_DIR=/app/uploads, LOG_DIR=/app/logs, any auth/feature flags your Pangolin fork supports

If you deploy without the Dockerfile and need Nixpacks overrides:

  • NIXPACKS_BUILD_CMD=pnpm install --frozen-lockfile && pnpm build
  • NIXPACKS_START_CMD=pnpm start -- --port 3000
  • NIXPACKS_NODE_VERSION=18

Attach persistent volumes

In Klutch.sh storage settings, add mount paths and sizes (no names required):

  • /app/uploads — user uploads and attachments.
  • /app/logs — optional logs if stored on disk.

Ensure these paths are writable inside the container.


Deploy Pangolin 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, including provider endpoint and keys.
  5. Attach persistent volumes for /app/uploads (and /app/logs if used) sized for your content and retention needs.
  6. Deploy. Your Pangolin instance will be reachable at https://example-app.klutch.sh; attach a custom domain if desired.

Sample API usage

Send a chat request (example endpoint; adjust to your build):

Terminal window
curl -X POST "https://example-app.klutch.sh/api/chat" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{"prompt":"Hello from Pangolin on Klutch.sh","model":"default"}'

Health checks and production tips

  • Add an HTTP probe to /health or / for readiness.
  • Enforce HTTPS at the edge; forward internally to port 3000.
  • Keep provider keys and tokens in Klutch.sh secrets; rotate them regularly.
  • Monitor storage usage on /app/uploads; resize before it fills.
  • Pin image versions and test upgrades in staging; back up data before updates.

Pangolin on Klutch.sh combines reproducible Docker builds with managed secrets, persistent storage, and flexible HTTP/TCP routing. With the Dockerfile at the repo root, port 3000 configured, and provider endpoints set, you can deliver a secure LLM interface without extra YAML or workflow overhead.