source: Klonkt/README.md@ 283f618

main
Last change on this file since 283f618 was c648b04, checked in by Robin Genis <roboburr@…>, 3 months ago

docs: call out Node.js 20+ requirement in the self-hosting section

Co-Authored-By: Claude <noreply@…>

  • Property mode set to 100644
File size: 7.2 KB
Line 
1# Klonkt
2
3Your own, **self-hosted** corner of the web — for your story, your visuals and
4your sound. Built on **Node + SQLite + htmx**: lightweight, server-rendered, and
5yours. No algorithm, no ads, no platform sitting in between.
6
7## What it does
8
9- **Solo** — one personal site, entirely yours, on your own domain.
10- **Blog & photos** — posts with cover, tags, timeline or grid.
11- **Host your own music** — built-in audio player with tracks, albums and playlists.
12- **Fediverse-native** — your posts federate over **ActivityPub**: people follow,
13 like, boost and reply from Mastodon (or another Klonkt). You can follow accounts,
14 see a home timeline, and reply/like back — Klonkt is a full fediverse client.
15- **Grow**: newsletter, download-for-email, EPK/press kit, link-in-bio,
16 show calendar, and **cookie-free statistics**.
17- **Circles** — connect your site with other Klonkt sites and show each other's
18 public posts; decentralized, with no central platform (Ed25519-signed federation).
19- **Themes & languages** — multiple palettes (light + dark), interface in EN/NL/DE.
20- **Installable (PWA)**, **privacy-first** (self-hosted fonts, no tracking).
21
22### Lite mode (no audio)
23
24Set `KLONKT_AUDIO=off` in `.env` to disable the entire audio/music feature.
25Klonkt then runs as a lightweight **blog/photo/EPK/links site without ffmpeg** —
26ideal for minimal hosting. Circles and external embeds
27(YouTube/SoundCloud/Spotify) keep working.
28
29## Self-hosting
30
31Klonkt is a **Node app** — run it on a **VPS, in Docker, or on a Node hosting
32platform (PaaS)**. **Not** on classic shared PHP hosting. The database (SQLite)
33creates itself on first start.
34
35> **Requires [Node.js](https://nodejs.org/) 20 or newer.** The one-command VPS
36> installer and the Docker image include it; only a manual install needs you to
37> provide it.
38
39### Option A — One-command VPS installer (recommended)
40
41**Good if:** you have (or just rented) a fresh, empty Debian/Ubuntu VPS and want
42the easiest path. This single line does everything — installs Node 20, sets up
43Caddy for automatic HTTPS, runs Klonkt as a background service that auto-restarts
44on reboot, and adds an update command. It's coexistence-safe (if the server
45already runs something it picks a free port and skips Caddy), but a clean VPS is
46simplest. Point your domain's DNS (A + AAAA records) at the server first, then run
47as root:
48
49```bash
50curl -fsSL https://klonkt.com/install.sh | sudo bash -s -- --domain yourdomain.com
51```
52
53Then open `https://yourdomain.com` and finish setup in the browser. Update anytime
54with `klonkt-update`.
55
56### Option B — Docker
57
58**Good if:** you already use Docker, or want everything bundled in one isolated
59container. Node, ffmpeg and cwebp are inside the image — you only need Docker +
60Docker Compose.
61
62```bash
63git clone https://github.com/roboburr/klonkt.git
64cd klonkt
65cp .env.example .env # works as-is; optionally set PUBLIC_BASE_URL to your domain
66docker compose up -d
67```
68
69`SESSION_SECRET` is auto-generated on first start, so the defaults work as-is.
70Klonkt runs on port 3000 — put your own reverse proxy in front for HTTPS (see
71step 5 of Option C). Data (database + media) stays in the `klonkt-data` volume,
72even across updates. Update: `git pull && docker compose up -d --build`.
73
74### Option C — manual (Node 20+), step by step
75
76**Good if:** you want full control, are adding Klonkt to a server you already
77manage, or just want to test it locally.
78
79**1. Get the code & install dependencies**
80
81```bash
82git clone https://github.com/roboburr/klonkt.git
83cd klonkt
84npm ci
85```
86
87**2. Create your config.** `SESSION_SECRET` (the key that signs login cookies) is
88auto-generated on first start, so this works as-is. For production, set
89`PUBLIC_BASE_URL` to your site address (e.g. `https://yourdomain.com`) so email &
90login links are correct:
91
92```bash
93cp .env.example .env
94nano .env # optional: PUBLIC_BASE_URL, plus SMTP if you want it
95```
96
97**3. Start it** — the SQLite database is created automatically on first start:
98
99```bash
100npm start # runs on http://localhost:3000
101```
102
103Just testing locally? Stop here and open `http://localhost:3000`.
104
105**4. Keep it running** across crashes and reboots (easiest is pm2):
106
107```bash
108npm install -g pm2
109pm2 start src/server.js --name klonkt
110pm2 save && pm2 startup # run the one command it prints, once
111```
112
113**5. Add HTTPS** with a reverse proxy in front. With Caddy (automatic
114certificates), put this in `/etc/caddy/Caddyfile` and reload Caddy:
115
116```caddy
117yourdomain.com {
118 reverse_proxy localhost:3000
119}
120```
121
122By default the app binds to `127.0.0.1` (via `HOST` in `.env`), so only your
123reverse proxy can reach it — not the open internet. Local testing on the same
124machine (`localhost:3000`) still works. Only set `HOST=0.0.0.0` if you need direct
125external access without a proxy (then open the port in your firewall and add HTTPS
126yourself).
127
128(`cwebp` is optional — `apt install webp` — for WebP image conversion.)
129
130### HTTPS (Docker / bare Node)
131
132Put a reverse proxy in front of the app. With **Caddy** (automatic Let's Encrypt):
133
134```caddy
135yourdomain.com {
136 reverse_proxy localhost:3000
137 encode gzip zstd
138}
139```
140
141(The VPS installer sets up Caddy + HTTPS for you already.)
142
143### First run
144
145Open your site → you get the **setup wizard**: pick your language, name your site
146and create your admin. The **first user automatically becomes the administrator**;
147registration then closes. Lost your password?
148`npm run reset-admin` (Docker: `docker compose exec klonkt npm run reset-admin`).
149
150## Configuration (`.env`)
151
152| Variable | Required | What |
153|---|---|---|
154| `SESSION_SECRET` | ✅ | Random string of ≥32 characters |
155| `PUBLIC_BASE_URL` | ✅ | Canonical URL (e.g. `https://yourdomain.com`) |
156| `SMTP_HOST` / `_PORT` / `_USER` / `_PASS` / `_FROM` | — | Email for password reset + newsletter |
157| `KLONKT_DEFAULT_LANG` | — | Default language for visitors (`en`/`nl`/`de`) |
158| `KLONKT_AUDIO` | — | `off` = lite mode (no audio/ffmpeg) |
159
160## Stack
161
162- **Runtime:** Node 20+
163- **Web:** Express + Helmet + express-session
164- **DB:** better-sqlite3 (WAL), self-migrating on boot
165- **Templates:** EJS (server-rendered) + **htmx 1.9** (vendored, no build step)
166- **Audio:** ffmpeg-static (bundled)
167- **Circles:** Ed25519-signed pull (libsodium via Node crypto)
168- **Fonts:** self-hosted variable woff2 (Fraunces / Plus Jakarta Sans)
169
170## Project structure
171
172```
173src/
174├── server.js # Express bootstrap + route mounting
175├── config/ # database, mailer, feature flags
176├── db/migrations/ # SQLite schema (001-init.sql)
177├── middleware/ # site resolving, auth, render (htmx-aware)
178├── routes/ # per-resource Express routers (posts, auth, admin-*, circle, …)
179├── services/ # domain logic (federation, stats, mailer, permissions, …)
180├── views/ # shell.ejs + partials/ + pages/ (EJS)
181└── assets/ # css/ (palette tokens + components), js/ (htmx, player), fonts/
182```
183
184## License
185
186**AGPL-3.0-or-later** — see [LICENSE](LICENSE). Klonkt is free software: you may
187use, study, modify and distribute it. The AGPL does require that a modified
188version you offer as a network service makes its source code available to the
189users of that service. Made by robo.burr (Robin Genis) ·
190<https://klonkt.com>
Note: See TracBrowser for help on using the repository browser.