source: Klonkt/README.md@ 09ee2bd

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

feat: auto-generate SESSION_SECRET if not set (zero-config Docker/manual)

If SESSION_SECRET is missing, generate a strong one on first boot and persist it
to <dataDir>/.session-secret (stable across restarts/updates). Env var still wins.
PUBLIC_BASE_URL already falls back to the request host. So Docker (B) and manual
(C) installs now run with no required .env editing. Docs + .env.example updated;
docker-compose comment translated to English.

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

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