Deploying a Lemmy App
Introduction
Lemmy is an open-source, federated link aggregator and forum platform built with Rust and Elixir. Deploying Lemmy with a Dockerfile on Klutch.sh provides reproducible builds, managed secrets, and persistent storage for media and database data—all managed from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, sample API usage, and production best practices.
Prerequisites
- A Klutch.sh account (create one)
- A GitHub repository containing your Lemmy code/config (GitHub is the only supported git source)
- Docker familiarity and Rust/Elixir basics
- PostgreSQL credentials
- Storage for media uploads, thumbnails, and logs
For onboarding, see the Quick Start.
Architecture and ports
- Lemmy serves HTTP on port
8536by default; set the internal container port to8536. -(If you deploy Pictrs for media, run it as a separate app on port127.0.0.1:8537internally; on Klutch.sh use a separate app with HTTP or TCP as needed.) - PostgreSQL should run as a separate Klutch.sh TCP app, exposed on port
8000, connected internally on5432. - Persistent storage is required for media and recommended for logs.
Repository layout
lemmy/├── config/ # Lemmy configuration files├── Dockerfile # Must be at repo root for auto-detection├── media/ # Media uploads (mount as volume)├── pictrs/ # Optional pictrs media service configs├── README.md└── .env.example # Template only; no secretsKeep secrets out of Git; store them in Klutch.sh environment variables.
Installation (local) and starter commands
Test locally before pushing to GitHub:
docker run --rm -p 8536:8536 \ -e LEMMY_DATABASE_URL=postgres://lemmy:password@localhost:5432/lemmy \ dessalines/lemmy:latestOptional helper start.sh for portability and Nixpacks fallback:
#!/usr/bin/env bashset -euo pipefailexec ./lemmy_serverMake it executable with chmod +x start.sh.
Dockerfile for Lemmy (production-ready)
Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker selection in the UI):
FROM dessalines/lemmy:latest
WORKDIR /app
# Copy custom configs if neededCOPY config /app/config
EXPOSE 8536CMD ["./lemmy_server"]Notes:
- Pin the image tag (e.g.,
:0.19.4) for reproducible builds. - If you run pictrs separately, deploy it as its own app with port settings appropriate to your setup.
Environment variables (Klutch.sh)
Set these in the Klutch.sh app settings (Secrets tab) before deploying:
PORT=8536LEMMY_DATABASE_URL=postgres://<user>:<password>@<host>:<port>/<db>LEMMY_HOSTNAME=example-app.klutch.shLEMMY_UI_REDIRECT=https://example-app.klutch.shRUST_LOG=infoPICRTS__URL(if using an external pictrs media service)
If you deploy without the Dockerfile and need Nixpacks overrides:
NIXPACKS_BUILD_CMD="echo Lemmy uses prebuilt image"NIXPACKS_START_CMD=./lemmy_serverNIXPACKS_RUST_VERSION=1.72NIXPACKS_ELIXIR_VERSION=1.15
These keep Lemmy 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/media— media uploads and thumbnails./app/logs— optional logs if you keep them on disk.
Ensure these paths are writable inside the container.
Deploy Lemmy 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 Lemmy.
- Set the internal port to
8536. - Add the environment variables above (database URL, hostname, pictrs URL if used, and any
NIXPACKS_*overrides if you temporarily deploy without the Dockerfile). - Attach persistent volumes for
/app/media(and/app/logsif used), selecting sizes that fit your content and logging needs. - Deploy. Your Lemmy instance will be reachable at
https://example-app.klutch.sh; attach a custom domain if desired.
For PostgreSQL on Klutch.sh, create a separate TCP app, expose it on port 8000, and point LEMMY_DATABASE_URL to that endpoint (internal port 5432).
Sample API call
Fetch site info to verify deployment:
curl -X GET "https://example-app.klutch.sh/api/v3/site" \ -H "Content-Type: application/json"Health checks and production tips
- Add a reverse proxy health check to
/api/v3/siteor a lightweight status route. - Enforce HTTPS at the edge; forward HTTP to port 8536 internally.
- Pin image tags and upgrade intentionally with DB backups.
- Monitor disk usage on
/app/mediaand/app/logs; resize volumes before they fill. - Back up PostgreSQL and media regularly; do not rely on container filesystems for durability.
Lemmy on Klutch.sh combines reproducible Docker builds with managed secrets, persistent storage for media, and flexible HTTP/TCP routing. With the Dockerfile at the repo root and port 8536 configured, you can run a federated link aggregator without extra YAML or workflow overhead.