Deploying a KeyDB App
Introduction
KeyDB is a high-performance, multi-threaded Redis-compatible database. Deploying KeyDB with a Dockerfile on Klutch.sh gives you reproducible builds, managed secrets, and persistent storage for in-memory data persisted to disk—all managed from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, and best practices for reliable caching and data durability.
Prerequisites
- A Klutch.sh account (create one)
- A GitHub repository containing your KeyDB configuration (GitHub is the only supported git source)
- Docker familiarity and basic Redis/KeyDB knowledge
- Storage for append-only files (AOF) and snapshots
For setup basics, see the Quick Start.
Architecture and ports
- KeyDB listens on TCP port
6379; set the internal container port to6379and choose TCP traffic in Klutch.sh. - Persistent storage is required for
/datato retain snapshots/AOF. - For replication, expose additional ports as needed or configure replication via environment variables.
Repository layout
keydb/├── keydb.conf # Optional custom config├── Dockerfile # Must be at repo root for auto-detection├── scripts/ # Helper scripts (optional)└── README.mdKeep secrets (passwords, TLS certs) in Klutch.sh environment variables, not in Git.
Installation (local) and starter commands
Quick local run:
docker run --rm -p 6379:6379 \ -v $(pwd)/data:/data \ eqalpha/keydb:alpine \ keydb-server /etc/keydb/keydb.conf --appendonly yesOptional helper start.sh for portability and Nixpacks fallback:
#!/usr/bin/env bashset -euo pipefailexec keydb-server /etc/keydb/keydb.conf --appendonly yesMake it executable with chmod +x start.sh.
Dockerfile for KeyDB (production-ready)
Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker selection in the UI):
FROM eqalpha/keydb:alpine
WORKDIR /app
# Copy custom config if providedCOPY keydb.conf /etc/keydb/keydb.conf
EXPOSE 6379CMD ["keydb-server", "/etc/keydb/keydb.conf", "--appendonly", "yes"]Notes:
- Pin the image tag (e.g.,
eqalpha/keydb:6.3.4-alpine) for reproducible behavior. - Add TLS certs via a volume and reference them in
keydb.confif needed.
Environment variables (Klutch.sh)
Set these in the Klutch.sh app settings (Secrets tab) before deploying:
PORT=6379KEYDB_PASSWORD=<strong-password>(if usingrequirepassin config)KEYDB_APPENDONLY=yesKEYDB_SAVE=900 1(example snapshot policy)KEYDB_MAXMEMORY=512mb(adjust as needed)
If you deploy without the Dockerfile and need Nixpacks overrides:
NIXPACKS_BUILD_CMD="echo KeyDB uses prebuilt image"NIXPACKS_START_CMD=keydb-server /etc/keydb/keydb.conf --appendonly yesNIXPACKS_JDK_VERSION=17(not typically needed, but listed for completeness)
These keep KeyDB 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):
/data— required for AOF/snapshots./etc/keydb— optional if you want to persist custom configs or TLS certs.
Ensure these paths are writable inside the container.
Deploy KeyDB 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 TCP traffic for KeyDB.
- Set the internal port to
6379. - Add the environment variables above (password, append-only settings, memory limits, and any
NIXPACKS_*overrides if you temporarily deploy without the Dockerfile). - Attach persistent volumes for
/data(and/etc/keydbif used), selecting sizes that fit your persistence and configuration needs. - Deploy. Your KeyDB instance will be reachable at
example-app.klutch.sh:8000over TCP for clients.
Sample code (Node.js client)
import { createClient } from "redis";
const client = createClient({ url: "redis://:PASSWORD@example-app.klutch.sh:8000",});
await client.connect();await client.set("hello", "keydb-on-klutch");const value = await client.get("hello");console.log(value);await client.disconnect();Health checks and production tips
- Use
PINGorINFOvia your monitoring stack to verify health. - Enforce authentication and TLS in production; keep credentials in Klutch.sh secrets.
- Monitor memory and disk usage; adjust
maxmemoryand resize/dataas needed. - Keep image tags pinned; upgrade intentionally.
- For replication or sharding, deploy multiple KeyDB instances with appropriate config and connect them accordingly.
KeyDB on Klutch.sh combines reproducible Docker builds with managed secrets, persistent volumes for AOF/snapshots, and flexible TCP routing. With the Dockerfile at the repo root and ports set to 6379 internally (8000 externally for clients), you can deliver fast, durable caching and data storage without extra YAML or workflow overhead.