Skip to content

Deploying a Kener App

Introduction

Kener is an open-source knowledge management platform. Deploying Kener with a Dockerfile on Klutch.sh provides reproducible builds, managed secrets, and persistent storage for content and configuration—all managed from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, and best practices for a stable knowledge base.


Prerequisites

  • A Klutch.sh account (create one)
  • A GitHub repository containing your Kener code (GitHub is the only supported git source)
  • Docker familiarity and Node.js 18+ knowledge
  • Database credentials (PostgreSQL recommended) and optional Redis

For platform onboarding, see the Quick Start.


Architecture and ports

  • Serve Kener over HTTP; set the internal container port to 3000 (typical for Node apps).
  • For PostgreSQL and Redis, create separate Klutch.sh TCP apps, exposed on port 8000, and connect internally on 5432/6379.
  • Persistent storage is recommended for uploads, cache, and logs.

Repository layout

kener/
├── apps/server/ # Backend services
├── apps/web/ # Frontend UI
├── storage/ # Uploads and cached assets (mount as volume)
├── 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

Keep 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:

Terminal window
pnpm install
pnpm build
pnpm start -- --port 3000

If you run migrations, add:

Terminal window
pnpm prisma migrate deploy

Optional helper start.sh for portability and Nixpacks fallback:

#!/usr/bin/env bash
set -euo pipefail
pnpm prisma migrate deploy || true
pnpm start -- --port 3000

Make it executable with chmod +x start.sh.


Dockerfile for Kener (production-ready)

Place this Dockerfile at the repository 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++) in the build stage if native modules are required.
  • Keep storage/ writable and mount it as a volume for uploads and cached assets.

Environment variables (Klutch.sh)

Set these in the Klutch.sh app settings (Secrets tab) before deploying:

  • NODE_ENV=production
  • PORT=3000
  • APP_BASE_URL=https://example-app.klutch.sh
  • DATABASE_URL=postgres://<user>:<password>@<host>:<port>/<db>
  • REDIS_URL=redis://<user>:<password>@<host>:<port> (if using Redis)
  • JWT_SECRET=<jwt-secret> or relevant auth secret
  • STORAGE_DIR=/app/storage/uploads

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

These keep Kener 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/storage/uploads — for user-generated content.
  • /app/.cache — optional cache to speed rebuilds if your app writes there.

Ensure these paths are writable inside the container.


Deploy Kener 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.
  1. Connect the GitHub repository; Klutch.sh automatically detects the Dockerfile.
  2. Choose HTTP traffic for Kener.
  3. Set the internal port to 3000.
  4. Add the environment variables above (database/Redis URLs, auth secret, and any NIXPACKS_* overrides if you temporarily deploy without the Dockerfile).
  5. Attach persistent volumes for /app/storage/uploads (and /app/.cache if used), selecting sizes that fit your storage needs.
  6. Deploy. Your Kener instance will be reachable at https://example-app.klutch.sh; attach a custom domain if desired.

Health checks and production tips

  • Add a /health endpoint that checks DB/Redis connectivity.
  • Enforce HTTPS at the edge; forward HTTP to port 3000 internally.
  • Monitor storage usage on mounted paths and resize before they fill.
  • Keep lockfiles committed and Node versions pinned for reproducible builds.
  • Back up databases and uploads regularly; do not rely on container filesystems for durability.

Kener on Klutch.sh combines reproducible Docker builds with managed secrets, persistent storage for uploads, and flexible HTTP/TCP routing. With the Dockerfile at the repo root and ports set to 3000 for the app (8000 externally for TCP databases or caches), you can deliver a dependable knowledge platform without extra YAML or workflow overhead.