readest/docker
esmaeelE 7893fa9167
Some checks are pending
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
CodeQL Advanced / Analyze (rust) (push) Waiting to run
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Publish Docker image / build (linux/amd64, ubuntu-latest) (push) Waiting to run
Publish Docker image / merge (push) Blocked by required conditions
Build with Nix / tests (push) Waiting to run
PR checks / test_extensions (push) Waiting to run
PR checks / test_web_app (2) (push) Waiting to run
PR checks / nix_flake_check (push) Waiting to run
PR checks / rust_lint (push) Waiting to run
PR checks / koplugin_rust_lint (push) Waiting to run
PR checks / build_web_app (push) Waiting to run
PR checks / test_web_app (1) (push) Waiting to run
PR checks / build_tauri_app (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Deploy to vercel on merge / build_and_deploy (push) Waiting to run
Support handwriting annotation (#6674)
* Add handwriting annotations with optional BOOX pen support (#3673)

- services/handwriting: platform-neutral ink model (normalized,
  page-relative coords, versioned schema), coordinate transform,
  canvas renderer, editor with undo/redo/erase, capability detection,
  and BookConfig persistence (device-local, excluded from cloud sync
  like the existing paired-audiobook field). 44 unit tests.
- Generic pointer-event backend works everywhere (web/desktop/iOS/
  non-BOOX Android); BOOX raw-drawing is an additive fast path chosen
  automatically via detectPenCapabilities().
- Native bridge: query_pen_capabilities/start_raw_drawing/
  stop_raw_drawing/set_raw_drawing_enabled commands added to
  tauri-plugin-native-bridge (Rust: commands/mobile/desktop/lib/
  build.rs + permissions).
- BOOX Pen SDK isolated behind a new Gradle 'pen' flavor dimension
  (genericPen default / booxPen opt-in) so default/FOSS builds never
  add BOOX's Maven repo or dependency; rationale and build docs in
  android/README-pen.md. PenInputController interface keeps every
  Onyx SDK type out of NativeBridgePlugin.kt.
- Reader UI: HandwritingOverlay/Canvas/Toolbar + useHandwriting hook,
  mounted in BooksGrid next to FoliateViewer. PDF pages are keyed
  precisely by page index; EPUB ink is anchored per-section (documented
  limitation: reflow has no fixed page).

Verified: tsc --noEmit clean, biome clean, full handwriting test
suite green (44/44).

NOT verified (no Android SDK/NDK or BOOX hardware in this
environment): android/src/booxPen/** has not been compiled — see
android/README-pen.md for what to check before shipping the booxPen
flavor. The Rust plugin changes have not been built with cargo/tauri
CLI (not installed here) but follow the existing refresh_eink_screen
command's pattern exactly across every layer they touch.

* add handwritten

* chore(android): update icons and add Android build docs

- Regenerate app icons with pnpm tauri icon
- Simplify ic_launcher.xml via tauri android init
- Add ANDROID_BUILD.md with build instructions

* docs(android): document build fixes for Android APK build

- Java 21 requirement (Gradle 8.14.3 fails on Java 25)
- AGP downgraded from 8.11.0 to 8.7.3
- Aliyun Maven mirror for offline Google repo access
- buildToolsVersion 35.0.0 pinning
- compileSdk warning suppression

* test(browser): update annotation popup screenshots for added handwriting tool

* chore: drop Android icon regeneration and local build doc from PR

* fix(test): restore upstream ExportMarkdownDialog test and add getConfig mock

* refactor(handwriting): rework ink anchoring, persistence and BOOX pen path

Ink placement:
- Key fixed-layout ink by section index instead of the location counter,
  which collided for adjacent PDF pages.
- Anchor reflowable ink to the page-start CFI and reuse any stored anchor
  inside the visible range, so ink no longer repeats on every page of a
  chapter.
- Normalize fixed-layout ink to the page frame, so it follows zoom and pan.
- Disable handwriting in scrolled mode.

Persistence:
- Clearing the last inked page now sticks (the store merges partials).
- Imports update the store before the live editor reloads.
- Save on committed edits only, debounced to disk; simplify strokes on
  commit instead of on export.
- Ink written by a newer schema is never overwritten.

UI:
- Enter via View menu > Handwriting Mode; drop the always-visible floating
  button and the selection-popup tool.
- Single toolbar below the safe-area inset; no color swatches on B&W e-ink.
- The Notebook falls back to Notes when the Handwriting tab has nothing to
  show; rows are labelled by chapter and sorted in reading order.
- JSON export works for books that only have ink.
- Drop the restyle feature.

BOOX:
- Run the pen SDK on the WebView with density scaling, close the previous
  session on restart, and deliver each stroke on pen-up with normalized
  pressure.
- Only use raw drawing when an EMR pen digitizer is present, so pen-less
  readers keep finger drawing.
- Make the opt-in booxPen flavor build: repository in the app module,
  support-library exclusion, libc++ pickFirst, no stripping of prebuilt SDK
  libraries, and R8 rules.
- Remove the unused set_raw_drawing_enabled command.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(handwriting): tap ink to edit it; show every anchor on a reflowed page

- A single tap on existing ink enters handwriting mode instead of turning
  the page. Single clicks now carry their main-window position so overlays
  can hit-test them.
- A reflowed page shows the ink of every anchor in its visible range, not
  just one, so a smaller font no longer hides ink drawn on the next page.
  Eraser, Clear Page and Undo cover all of them as one step; new strokes
  go to the page's primary anchor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(handwriting): pin reflowable ink to the content it marks

Ink in reflowable books was stored in page coordinates, so any font,
spacing or margin change left it over the wrong text. Each stroke is now
bound to content and re-placed from the current layout:

- Ink over text or images binds to the range of words and elements it
  covers (underlines bind to the line above) and is stored normalized to
  that range's box. Re-fitting to the new box keeps its shape and topology
  through font size, font family, line height and margin changes.
- Margin ink binds to the nearest character and scales uniformly; strokes
  written in one burst share an anchor so a note stays in one piece.
- Reflowable ink is keyed per section; the notebook labels rows by the
  chapter of the inked text and jumps straight to it.
- Fixed-layout ink stays normalized to the page, which already tracks
  zoom and pan.

This replaces the page-start anchors and the multi-anchor workaround.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(handwriting): drawings as annotations; shape-aware morphing

Each drawing is now an `ink` booknote: listed with the other annotations
in the left sidebar (pen icon and the text it marks), navigable and
deletable there. A reflowable book gets one note per anchor, a fixed-layout
book one per page. Ink notes travel by file sync; Readest Cloud has no field
for stroke data yet, so they are kept out of its push. The notebook's
Handwriting tab and the separate handwriting import/export are removed; a
notebook canvas is left for a follow-up.

Pinned ink now morphs by its shape:
- flow (underline, strike-through): follows its words, split per line on a
  re-wrap; marks are resampled so they stay continuous.
- box (circle, box, scribble): fitted to the content it encloses, so an
  edge brushing the next line no longer widens it to the whole line.
- span (bar or bracket beside a paragraph): stretched along its lines,
  kept at its distance from the text edge.
- rigid (margin notes): moves and scales with the nearest character.
Boxes are measured within one column, so a range wrapping onto the next
page can no longer blow a drawing up across two pages.

Ink also shows in scrolled mode (read-only) for every loaded section or
page, and follows a PDF pinch live instead of jumping when it commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(handwriting): redesign drawing mode; one annotation per session

- Drawing starts from a pen button in the reader header (the View menu
  item is gone; tapping existing ink still opens it for editing).
- While drawing, the reader's header and footer give way to the mode's own
  bars: a top bar (Drawing, Done) and a bottom dock with the pen (color and
  size in a popover), eraser, undo, redo and page turning. Nothing can cover
  Done any more.
- Strokes still save as they are drawn, but everything drawn in one visit
  to drawing mode is one annotation in the sidebar, instead of one per
  stroke. Each stroke keeps its own text anchor (or page in fixed layout).
- A short underline that encloses nothing binds to the word it marks,
  rather than to whichever character happened to be nearest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(handwriting): draw in scrolled mode

Scrolled views show several sections (or PDF pages) at once, so drawing
was limited to paginated mode. Each finished stroke and eraser sweep is now
routed to the section or page it is drawn over, pinned with that section's
text anchoring (or normalized to that PDF page), while the live stroke
draws over the per-section ink layers. Undo follows the page last drawn
on, and the dock's arrows scroll a screen at a time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(handwriting): stronger strokes and room for the drawing bars

Pen widths are heavier (default 0.006 of the page width) and a finger
stroke no longer carries pressure: touch reports contact size, not
pressure, which thinned every finger stroke. Ordinary pen pressure now
draws the full pen width, so existing strokes render stronger too.

Drawing mode lives in the reader view state, and the viewer reserves
the top bar and dock bands in its margins (paged) and scroll padding
(scrolled) while it is on, the way the TTS mini player does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(handwriting): draw committed strokes as smoothly as live ones

A stroke was simplified on commit to within a pixel and then drawn as a
polyline, so small loops turned angular and pressure changed in steps
once the pen lifted. Keep points to a fifth of a pixel and wherever the
pressure changes, and draw strokes as quadratic curves through the
samples. Also add the drawingEnabled view state to two test fixtures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(handwriting): fill pen strokes as one antialiased outline

A pen stroke was stroked as many short pieces of different widths. Each
piece antialiased its own edge with round caps, so at every joint the soft
edges blended twice and the width stepped, which read as a jagged edge
next to native ink. Trace the stroke's outline around samples every 1.5px,
with the width interpolated along the curve, and fill it once. A single
contour has no inner edges for the rasterizer to blend, and points where
the inner side of a tight turn would fold back are skipped so no hole
opens there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(handwriting): start every drawing session with the pen

The eraser toggle outlived the drawing session, so turning drawing back on
after erasing left the eraser active and the first strokes wiped ink
instead of drawing, which looked like strokes were not being recorded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(handwriting): keep a Pencil stroke drawn right after a tap

iOS WebKit read a quick tap followed by a drag as its own double-tap or
text-selection gesture and withheld that touch from the page entirely, so
the stroke never reached the canvas. touch-action: none only stops panning
and zooming. The drawing surface now cancels the default of its touch
events, which leaves the touch sequence to the page while pointer events
still arrive, and is unselectable with no callout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(handwriting): draw from the instant annotation tools, save from the dock

Draw moves from its own header button into the header's instant
annotation tools. The top drawing bar is gone: its Done becomes a save
icon as the dock's last button, and only the dock's band is reserved
below the text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(handwriting): add a marker tool beside the pen

A marker draws a broad translucent band of even width with flat ends, for
highlighting what is under it. It is stroked as one path, so it does not
darken where it crosses itself, while separate marks still mix where they
cross. It ignores pressure, keeps its own highlighter colors and widths,
and the eraser sizes itself to one marker band instead of three. The dock
shows pen, marker and eraser side by side; tapping the active tool opens
its options. Marker ink is stored with tool: 'marker'; pen ink is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(handwriting): match the pen and marker buttons to the rest of the dock

The tool buttons used a different icon set and a wider pill with a color
dot and caret. They now use the dock's line icons in the same square
button, with the active tool's ink color as a thin band under its icon.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(sidebar): lead each annotation with an icon for its kind

Bookmarks, highlights, notes and drawings each start with a small round
badge, so the kind of an item reads at a glance. The badge carries the
kind's name for screen readers and replaces the inline pencil drawings
used to show.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(handwriting): save a drawing and keep drawing; close from the dock

Save now finishes the current drawing as one annotation and stays in
drawing mode, so the next strokes start a new annotation, with a short
toast when there was ink to save. A Close button at the end of the dock
leaves drawing mode. Strokes are still saved as they are drawn, so
neither discards anything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(sync): sync handwriting strokes through Readest Cloud

Adds an ink jsonb column to book_notes (migration 026, folded into the
base schema) and carries ink notes through the notes sync instead of
leaving them to file sync only.

- The sync transform maps strokes to and from the column. Other notes
  never send the key, so an upsert does not clear stored strokes, and a
  pulled row without strokes carries no key, so merging it cannot wipe
  strokes held locally.
- Drawings are pushed when they change and never get an xpointer, which
  keeps every KOReader plugin version from importing one as a highlight.
- Committed points are rounded to 1/10000 of the page (pressure to
  1/100), which more than halves what each drawing stores and syncs.

The column has to exist before a server running this code receives a
drawing, so apply the migration to the database first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Readest Agent <agent@readest.local>
Co-authored-by: Huang Xin <chrox.huang@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 21:31:38 +02:00
..
volumes Support handwriting annotation (#6674) 2026-10-11 21:31:38 +02:00
.env.example feat(payments): separate storage and customization entitlements, unlock all when self-hosted (#5996) 2026-09-01 07:37:42 +02:00
compose.build.yaml feat(docker): add GHCR and Docker Hub image publishing (#4250) 2026-05-21 19:57:35 +02:00
compose.dev.yaml fix(docker): fix Docker image latest tag and production runtime errors; add dev compose file, Codespace support, and semver release tagging (#7) (#4277) 2026-05-23 10:39:15 +08:00
compose.yaml docker: pull minio images from quay.io, Docker Hub removed them (#6196) 2026-09-16 17:27:50 +02:00
nginx.conf.example fix(docker): apply db migrations on first boot and let the font CDN be overridden (#5550) (#5551) 2026-08-07 10:19:44 +02:00
README.md docker: pull minio images from quay.io, Docker Hub removed them (#6196) 2026-09-16 17:27:50 +02:00

Self-Hosting with Docker/Podman with Compose

Stack

service Image Description
client ghcr.io/readest/readest readest frontend
db supabase/postgres psql db with supabase extensions
kong kong:2.8.1 api gateway routing requests to supabase services
auth supabase/gotrue:v2.185.0 auth service (email, JWT)
rest postgrest/postgrest:v14.3 psql rest api
minio quay.io/minio/minio s3 storage
minio-setup quay.io/minio/mc helper container to create s3 buckets

Exposed ports

Port Service
3000 readest
8000 kong API gateway
9000 MinIO S3 API
9001 MinIO console UI

Running with Docker/Podman Compose

1. setup .env

cp docker/.env.example docker/.env

update docker/.env:

  • update POSTGRES_PASSWORD to a strong password (32+ chars)
  • update JWT_SECRET to a random secret (32+ chars)
  • regenerate ANON_KEY and SERVICE_ROLE_KEY as HS256 JWTs signed with your JWT_SECRET (use jwt.io or a similar tool):
    • ANON_KEY payload: {"role": "anon"}
    • SERVICE_ROLE_KEY payload: {"role": "service_role"}
  • set MINIO_ROOT_PASSWORD to a strong password

2. Start the Stack (pull prebuilt client image)

run from the docker/ directory:

cd docker
docker compose up -d

this pulls ${READEST_IMAGE} (default: ghcr.io/readest/readest:latest) instead of building the client locally. the web client now reads SUPABASE_PUBLIC_URL, SUPABASE_ANON_KEY, API_BASE_URL, OBJECT_STORAGE_TYPE, SELF_HOSTED, STORAGE_FIXED_QUOTA, and TRANSLATION_FIXED_QUOTA from runtime container env, so custom self-hosted values work with pulled images.

SELF_HOSTED unlocks every premium feature — third-party cloud sync (WebDAV, Google Drive, S3, OneDrive), offline Read Aloud downloads, Send to Readest — with or without a signed-in user. the image defaults it to true, so a pulled image is unlocked even if your compose.yaml predates the variable. set SELF_HOSTED=false in docker/.env only if you run a hosted service that sells the plans.

if you prefer Docker Hub, set READEST_IMAGE in docker/.env, for example:

READEST_IMAGE=docker.io/your-dockerhub-username/readest:latest

replace your-dockerhub-username with the Docker Hub namespace that publishes your readest image. for official images, use the namespace configured for this repository's Docker Hub publishing secrets.

published tags:

  • latest: rolling image from the default branch and from release events
  • <release-tag> (for example v1.2.3): published from release events
  • main: rolling image from the default branch
  • sha-<commit>: immutable commit tag

Build locally instead of pulling

Prerequisites for local builds: the packages/foliate-js and packages/simplecc-wasm git submodules must be initialized before building:

git submodule update --init packages/foliate-js packages/simplecc-wasm

In GitHub Codespaces this is done automatically via .devcontainer/devcontainer.json.

cd docker
docker compose -f compose.yaml -f compose.build.yaml up --build -d

3. Access

  • Readest app: http://localhost:3000
  • MinIO console: http://localhost:9001 (login with MINIO_ROOT_USER / MINIO_ROOT_PASSWORD)

Upgrading an existing deployment

pulling a newer client image does not touch the database volume, and the first-boot hook only runs when that volume is empty. so after an upgrade, apply any new migrations yourself:

cd docker
docker compose pull
docker compose up -d
docker compose exec db /docker-entrypoint-initdb.d/zz-readest-migrations.sh

the script records what it applied in readest_meta.migrations and skips those next time, so it is safe to repeat after every upgrade.

if you had previously patched your database by hand, the script may stop on an already exists error. record that file as applied and run it again:

docker compose exec db psql -U supabase_admin -c \
  "INSERT INTO readest_meta.migrations (name) VALUES ('002_add_book_shares.sql') ON CONFLICT DO NOTHING"

Hot Reload (development)

Prerequisites: submodules must be initialized (see above).

to develop using the compose stack, use compose.dev.yaml which sets the build target to development-stage (Next.js dev server) and mounts your local repo for hot reload:

cd docker
docker compose -f compose.yaml -f compose.dev.yaml up --build -d

the first mount overlays your local repo into the container. the remaining anonymous volumes shadow the directories that were pre-built inside the image, so the container's installed deps and vendor assets are used instead of what's on your host.

Stop the Stack

cd docker
docker compose down

to also remove volumes (database and storage data):

cd docker
docker compose down -v

Database schema

path role
volumes/db/init/schema.sql base schema (books, book_configs, book_notes, files)
volumes/db/migrations/*.sql every schema change since, applied in filename order
volumes/db/apply-migrations.sh applies the migrations and records them in readest_meta.migrations

on an empty database volume the supabase image runs everything under /docker-entrypoint-initdb.d in glob order: its own migrate.sh (supabase core schema plus init-scripts/100-schema.sql, which is schema.sql), then zz-readest-migrations.sh, which is apply-migrations.sh. it globs the mounted migrations directory, so adding a migration file needs no compose change.


Serving from a custom domain

the browser talks to three of these services directly, so each needs a URL that resolves from outside the docker network:

variable what the browser uses it for
SITE_URL the readest client itself
SUPABASE_PUBLIC_URL kong, which routes /auth/v1/… and /rest/v1/…
S3_PUBLIC_ENDPOINT minio, reached through path-style presigned URLs

SUPABASE_PUBLIC_URL and S3_PUBLIC_ENDPOINT default to http://${HOST_IP}:<port>, which suits a plain IP/port deployment; set them in docker/.env to override that. putting everything on one origin also means no cross-origin requests at all:

HOST_IP=your-domain.com
SITE_URL=https://your-domain.com
API_EXTERNAL_URL=https://your-domain.com
ADDITIONAL_REDIRECT_URLS=https://your-domain.com/**
SUPABASE_PUBLIC_URL=https://your-domain.com
S3_PUBLIC_ENDPOINT=https://your-domain.com

nginx.conf.example is a working starting point for terminating TLS in front of the stack. two things it gets right that are easy to miss: the Host header has to reach minio unchanged or the presigned signatures will not verify, and the request body limit has to be lifted on the bucket location or large book uploads are truncated.

CJK fonts on a custom domain

the reader loads a few CJK webfont bundles from Readest's CDN, which only sends Access-Control-Allow-Origin for readest.com origins, so the browser blocks them on a self-hosted domain. mirror https://storage.readest.com/public/font/dist/<Family>/ (and the .woff2 files it references) onto a path your proxy serves, then point the client at it:

FONT_BASE_URL=https://your-domain.com/fonts

leaving FONT_BASE_URL empty keeps the default CDN. system and Google fonts are unaffected either way.


Building the Dockerfile standalone

docker build \
  --target production-stage \
  --build-arg NEXT_PUBLIC_APP_PLATFORM=web \
  -t readest-client \
  .

run the built image:

docker run -p 3000:3000 \
  -e SUPABASE_URL=http://host.docker.internal:8000 \
  -e SUPABASE_PUBLIC_URL=http://localhost:8000 \
  -e SUPABASE_ANON_KEY=<anon-key> \
  -e SUPABASE_ADMIN_KEY=<service-role-key> \
  -e API_BASE_URL=http://localhost:3000 \
  -e OBJECT_STORAGE_TYPE=s3 \
  -e S3_ENDPOINT=http://host.docker.internal:9000 \
  -e S3_PUBLIC_ENDPOINT=http://localhost:9000 \
  -e S3_REGION=us-east-1 \
  -e S3_BUCKET_NAME=readest-files \
  -e S3_ACCESS_KEY_ID=<minio-user> \
  -e S3_SECRET_ACCESS_KEY=<minio-password> \
  -e STORAGE_FIXED_QUOTA=1073741824 \
  -e TRANSLATION_FIXED_QUOTA=50000 \
  readest-client

on Linux, some Docker setups do not resolve host.docker.internal by default. in that case, either replace it with your host IP or run with: --add-host=host.docker.internal:host-gateway.