- TypeScript 95%
- JavaScript 4%
- Shell 0.6%
- Dockerfile 0.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| .githooks | ||
| client | ||
| locales | ||
| server | ||
| worker | ||
| .env.example | ||
| .gitignore | ||
| compose.dev.yml | ||
| deploy.json | ||
| LICENSE.md | ||
| limedoc.project.json | ||
| README.md | ||
| web-render.plugin.json | ||
| web-render.ts | ||
| web_render_dashboard_widget.tsx | ||
Web Render
Headless block rendering via Redis streams and web-render-worker.
Requirements
- Docker (or Podman with
DOCKER_CMD=podman) - That's it — everything else runs inside containers.
Quick start
# 1. Pull the dev image and set up .env
./ldcmd setup
# 2. Start the dev environment (app + Redis)
./ldcmd up
# 3. Open http://localhost:5173 in your browser
# 4. Edit plugin sources — HMR applies automatically
# 5. Run tests
./ldcmd test
# 6. Check types and import boundaries
./ldcmd check
Directory layout
web-render.plugin.json # Plugin manifest
web-render.ts # Server entry (defineLimedocPlugin)
web_render_editor_tool.tsx # Browser client (builds to client/*.js)
client/ # Pre-built browser bundles (committed)
limedoc.project.json # Store metadata (package download URLs)
compose.dev.yml # Dev compose (uses the published limedoc-dev image)
ldcmd # Bridge script — the only thing you run on your host
.env.example # Env var template — copy to .env and fill in OIDC values
ldcmd commands
| Command | What it does |
|---|---|
./ldcmd setup |
Pull limedoc-dev image, copy .env.example → .env |
./ldcmd up |
Start dev environment |
./ldcmd down |
Stop dev environment |
./ldcmd logs [service] |
Follow container logs |
./ldcmd sh [service] |
Open shell in container (default: app-dev) |
./ldcmd test |
Run plugin tests |
./ldcmd fmt |
Format sources |
./ldcmd lint |
Lint sources |
./ldcmd check |
Type-check + import boundary check |
./ldcmd pack |
Build zip + sha256 (CI also publishes sig.json) |
./ldcmd publish |
Pack and upload (needs .forgejo.env / PACKAGE_TOKEN) |
./ldcmd plugin install <id> |
Install a plugin dependency into the running env |
./ldcmd plugin ls |
List installed plugins |
Building client bundles
# Inside the container (run after editing .tsx files)
./ldcmd sh
deno task plugin:build -- /limedoc/plugins/web-render.plugin
Or directly:
./ldcmd check # runs build as part of the check
Production sidecar (host)
Pack Store / packs:install unpacks this plugin into the app only. The Docker
sidecar is not started by Limedoc (no Docker socket in the app). On the
deploy host:
ldcmd sidecar up web-render
# or: ldcmd up
Compose SoT: deploy.json + worker/docker-compose.yml (joins DOCKER_NETWORK_NAME).
Isolation
The worker runs untrusted page content (diagram sources, external URLs) in headless Chromium. Layers, inside out:
- Fetch egress wall (
worker/renderer.ts,worker/egress_policy.ts): block renders only see the syntheticrender.localorigin; external renders re-check every HTTP(S) request against the SSRF policy. - Page lockdown (
installPageLockdown): the Fetch domain does not see WebSocket, WebRTC or WebTransport, so every page getsNetwork.setBlockedURLs(ws://*, wss://*)and an init script that removesWebSocket,RTCPeerConnection& co. before page scripts run. Chromium is launched with--force-webrtc-ip-handling-policy=disable_non_proxied_udp(no WebRTC UDP outside a proxy). - Egress routing (optional):
RENDER_PROXY_SERVERsends all Chromium traffic through a forward proxy you control (allowlist there);RENDER_HOST_RESOLVER_RULESsets--host-resolver-rules(e.g.MAP * ~NOTFOUNDwhen you only use block renders, which never resolve DNS). --no-sandbox: in rootless containers Chromium's setuid / user namespace sandbox is unavailable under the default Docker seccomp profile, so the worker disables it (worker/runtime_guard.ts). A renderer exploit then runs with the worker's rights. What compensates: the image runs as a non-root user (RENDER_RUNTIME=prodrefuses root), the compose service drops all capabilities withno-new-privileges, the worker holds no secrets except a Redis user that can only touch render keys and (encrypted mode) its own derivedweb-rendersidecar key, never the global key, and it sits on its own network. If your runtime allows user namespaces (e.g. a seccomp profile permittingclone(CLONE_NEWUSER)), run withCHROMIUM_IN_CONTAINER=0to keep Chromium's sandbox on.
Guided setup: ldcmd redis secure (run by ldcmd bootstrap and
ldcmd update) creates the worker-only Redis ACL user and writes
WEB_RENDER_REDIS_URL; from 0.3.1 the worker compose refuses to start
without it. ldcmd sidecar isolate web-render adds the dedicated network
(attaching Redis and the app), WEB_RENDER_NETWORK_NAME and, in encrypted
mode, WEB_RENDER_SIDECAR_KEY. The manual steps below are the reference for
what they do.
Worker compose env contract (worker/docker-compose.yml, interpolated from
the deploy .env):
| Worker env | From deploy .env |
|---|---|
REDIS_URL |
WEB_RENDER_REDIS_URL (required) |
LIMEDOC_SIDECAR_KEY |
WEB_RENDER_SIDECAR_KEY (empty = plaintext) |
RENDER_PROXY_SERVER |
RENDER_PROXY_SERVER |
RENDER_HOST_RESOLVER_RULES |
RENDER_HOST_RESOLVER_RULES |
network render |
WEB_RENDER_NETWORK_NAME, else DOCKER_NETWORK_NAME |
Own Docker network
The worker needs Redis (and the app reaches its health port); it does not need Collabora, the search worker or anything else on the app network.
docker network create limedoc_render
docker network connect limedoc_render <redis-container>
docker network connect limedoc_render <app-container>
# deploy .env (passed with --env-file):
WEB_RENDER_NETWORK_NAME=limedoc_render
Re-run the network connect lines after the app or Redis containers are
recreated (or add the limedoc_render network to their compose services).
With external renders the network must keep internet egress (do not mark it
internal: true), or route it through RENDER_PROXY_SERVER. Remove the
extra_hosts: host.docker.internal entry from worker/docker-compose.yml if
Redis is not on the host.
Redis ACL user (Redis 7+)
The worker reads ctx:* (bundles) and res:* (resources) and reads/writes
render:* (request/response streams, sources, outputs, dead letters,
heartbeat). Give it a user limited to exactly that:
redis-cli ACL SETUSER web-render on '>CHANGE_ME' resetkeys resetchannels \
'~render:*' '%R~ctx:*' '%R~res:*' \
-@all +get +set +del +xadd +xack +xclaim +xrange +xpending +xreadgroup \
+xgroup\|create +ping +hello +auth +select +client\|setinfo +info
redis-cli ACL SAVE # or CONFIG REWRITE, depending on how ACLs are persisted
Then put the worker credentials into WEB_RENDER_REDIS_URL in the deploy
.env:
WEB_RENDER_REDIS_URL=redis://web-render:CHANGE_ME@redis:6379
Do not change the shared REDIS_URL: the app reads it too and needs its
own (broader) Redis user. The worker compose maps WEB_RENDER_REDIS_URL to
the worker's REDIS_URL and refuses to start when it is unset (before 0.3.1
it fell back to the app's REDIS_URL).
The worker masks the credentials in its startup log, and the app's render
diagnostics show the URL with user and password masked. Check with
redis-cli --user web-render --pass CHANGE_ME GET sessions:x → NOPERM.
If you changed RENDER_REQ_STREAM, RENDER_RESP_STREAM,
RENDER_DEAD_STREAM or RENDER_HEARTBEAT_KEY away from the render:
prefix, add those keys to the user.
Who decides where a result goes
The worker runs a browser on user content, so the app does not take its word
for what a reply may touch. When a job is submitted the app records
jobId → {format, routing meta (cache path, block, theme)} in process memory
and under web-render:job:{jobId} (TTL = source + result TTL + 1 h; sealed
in encrypted mode). That prefix is outside everything the worker's Redis user
is granted (render:*, read-only ctx:* / res:*), so the worker can
neither read nor forge a record. On a reply the app
- drops (acks, logs) a reply whose
jobIdit has no record for, - reads and deletes only
render:out:{jobId}, whateverresultKeyssays, - stores with the recorded format and meta, whatever the reply echoes (a difference is logged as a warning),
- refuses a result above
RENDER_RESULT_MAX_BYTES(app env, default 64 MiB;result_too_large).
Jobs in flight across an upgrade from a version without the record are dropped; block renders are re-enqueued by their plugins.
Browser lockdown
- The worker removes
REDIS_URLandLIMEDOC_SIDECAR_KEYfrom its own environment after reading them; Chromium, a child process, does not inherit them. - Workers (dedicated, shared, service) are not available to rendered pages:
the constructors are removed before any page script runs, the render origin
answers with
Content-Security-Policy: worker-src 'none', and every child target is attached paused and never resumed (Target.setAutoAttach). On external pages that also leaves cross-site iframes blank: their requests would bypass the egress guard of the page session. - Popups:
window.openreturns null and Chromium runs with--block-new-web-contents. - The consumer loops of app and worker read the stream on their own Redis
connection; other commands no longer wait behind
XREADGROUP BLOCK. - External mode publishes the health port on
127.0.0.1only (WEB_RENDER_HOST_BINDoverrides).
Encrypted storage mode
With CONTENT_VERSION_MODE=encrypted nothing the render pipeline persists is
plaintext (key names, stream names, ids and paths excepted):
- Cache files: the result sink (
server/result_sink.ts) writes rendered SVG / PNG / WebP through@/lib/plugin-sdk/plugin_cache_store.ts, i.e. the object facade (codec-encrypted, and on the shared port withSTORAGE_PORT=s3). Readers (readBlockRender, mindelixir rasters, the mindelixir topic-image cache undermindelixir/webimages/) use the same facade. - Redis: render sources (
render:src:*), results (render:out:*), request / response / dead-letter stream payloads, bundles (ctx:*) and resources (res:*) are sealed with theweb-rendersidecar key (docs/security/SIDECAR_ENCRYPTION.md; app:server/sidecar_seal.ts, worker:worker/sidecar_crypto.ts). Stream entries carryjobIdandrespondToin plaintext; bundles and resources move to kid-scoped keys (ctx:{app}:{profile}:{kid}:{version},res:{kid}:{cid}). Plaintextctx:*/res:*left from before encryption are never read and can be deleted.
The worker needs its key: ldcmd sidecar configure writes
WEB_RENDER_SIDECAR_KEY (mapped to LIMEDOC_SIDECAR_KEY); re-run it after a
key rotation and recreate the worker. Both sides reject unsealed input in
encrypted mode. Skew is reported, not silent:
- the worker heartbeat carries its key id; the app's web-render status turns
degraded(worker facetdown) with the fix inreason, andgetRenderPipelineDiagnostics().sidecarEncryption.skewnames it; - a worker without key (or with another key id) answers each job with a
plaintext error code (
sidecar_key_missing,sidecar_key_mismatch,sidecar_unsealed), so jobs fail at once with that code instead of timing out, and both sides log the fix once.
Packing and publishing
# Build the installable zip + sha256 sidecar (local)
./ldcmd pack
# Publish (needs .forgejo.env with PACKAGE_TOKEN, PACKAGE_OWNER)
./ldcmd publish
CI (Forgejo Actions, .forgejo/workflows/publish.yml) on push to main publishes
zip + sha256 + sig.json to Packages and Releases. Pack CI signs the
content hash with OpenBao Transit (Forgejo Actions OIDC). Actions secret
PACKAGE_TOKEN only — PACKAGE_OWNER is in the workflow env.
Developing with plugin dependencies
Your plugin may depend on another plugin at runtime. Three ways to include it:
1. Install via ldcmd (easiest, needs the app running)
./ldcmd up
./ldcmd plugin install media # fetches from PACKAGE_STORE_URL in .env
Set PACKAGE_STORE_URL in .env to point at the Forgejo package registry:
PACKAGE_STORE_URL=https://git.belowtoxic.cloud/api/packages/limedoc-plugins
2. Local bind-mount (no running app needed)
Download the pack zip, unzip it next to this directory, then add a volume to compose.dev.yml:
app-dev:
volumes:
- .:/limedoc/plugins/web-render.plugin
# Add the dependency:
- ../other-plugin.plugin:/limedoc/plugins/other.plugin
Then ./ldcmd up — the app loads all *.plugin directories in plugins/.
3. Multi-repo development (two plugins at once)
Check out the other plugin repo next to this one:
cd ..
git clone git@git.belowtoxic.cloud:limedoc-plugins/other.git other.plugin
Then add it as a bind-mount in compose.dev.yml as shown above. Both plugins
are mounted into the same app instance. No special ldcmd support required —
the app discovers every *.plugin directory at startup.
Startup order: The app loads plugins alphabetically. If your plugin
requiresanother, the dependency must be present on disk for the load plan to resolve. The composedepends_onin the sidecar template ensures the worker sidecar is healthy before the app starts, but for plugin-to-plugin dependencies no extra compose configuration is needed.
CI / CD
Push to main → Forgejo Actions runs .forgejo/workflows/publish.yml:
- Tests pass inside the
limedoc-devcontainer - Client bundles built; boundary check passes
plugin:packproducesweb-render-{version}.zip+.sha256- OpenBao signs the content hash →
web-render-{version}.sig.json - Zip, sha256, and sig.json uploaded to the generic package registry (store)
- Same artifacts attached to a Forgejo Release
v{version}(operators)
The app installs plugins from the generic package registry at PACKAGE_STORE_URL.
Using Podman instead of Docker
# In .env (or export before running):
DOCKER_CMD=podman
./ldcmd up
ldcmd detects podman compose automatically.
License
This pack is source-available under the Functional Source License, Version 1.1, ALv2 Future License (FSL-1.1-ALv2). Copyright 2026 Oliver Maklott (Belowtoxic e.U.).
You may use, modify, and redistribute it for any purpose other than a
Competing Use. Two years after a version is made available, that version is
also licensed under the Apache License 2.0. Third-party files under vendor/
keep the license shipped with those files.