* feat(crosspoint): sync CrossPoint 2.0 clippings with Readest highlights
CrossPoint 2.0's Sync Clippings first probes
{KOSync server}/api/v1/clippings/{document} for sync_version 2, and stops
the whole sync, progress included, when the probe fails. Readest's KOSync
endpoint had no such route, so a reader signed in with the Readest plugin
showed "Could Not Sync Clippings" and stopped syncing progress once the
setting was on.
- /api/crosspoint/api/v1/clippings/{document} serves the clippings API
(sync_version 2, cursor paging, tombstones). A clipping is a book_notes
highlight whose new `crosspoint` column holds the reader's anchor (spine
plus a code-point range), the way xpointer0/xpointer1 hold KOReader's.
Only items the firmware can decode are sent, up to the 256 an X3/X4
holds per book. A rewritten copy (Optimize EPUB) syncs as the library
book it is linked to, and its first clippings move to that book when
its progress upload links it.
- Readest apps turn a clipping into a CFI when they open the book, and
give each EPUB highlight a CrossPoint anchor when they push it (tried
once a session). Moving a highlight's range drops the old anchors.
- Migration 033 adds book_notes.crosspoint (nullable jsonb). Apply it
before the web deploy.
- Plugin README: CrossPoint 2.0 names and requirements, and highlights.
Fails without the change: useNotesSync-crosspoint (4 of 5, e.g. "turns a
clipping a reader synced into a highlight at its CFI"), transform "carries
the anchor in the crosspoint column, both ways", useAnnotationEditor "a
moved range drops the KOReader and CrossPoint anchors of the old one"
(expected the old xpointer to be undefined), and the route test "moves a
rewritten copy's clippings to the library book it gets linked to". The
clippings route tests can't run without the route.
Verified on a real X4 (CrossPoint 2.0.0) with Sync Clippings on: the
probe and uploads answer 200, a reader clipping shows in Readest on its
words, a Readest highlight shows on the X4, and deletions go both ways.
Reported by itsthisjustin (CrossPoint).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(crosspoint): sync a document a reader names by its file name
A reader set to match documents by file name (CrossPoint's default, and
the alternate lookup of its Smart Sync) sends md5 of the book's file
name, as KOReader does. Since #7237 Readest keeps the name a book was
imported under (books.original_filename), and #7253 digests it the same
way in Readest's own KOSync client.
Progress, clippings and reading sessions now resolve such a document to
the library book imported under that name, link it on first sight like a
rewritten copy, and move clippings saved under the name's id to the book.
When two books were imported under one name, the most recently read one
wins. A document that is a book's own id is never looked up by name, and
an NFD spelling of the name does not match.
Fails without the change: 5 of the 6 tests in "a document named by its
file name", e.g. "syncs it as the library book imported under that name,
linked on first sight" (the link write and the library book's queries
never happen). The sixth, a name no book has, passed before too.
Not run on a device: the books in the test library were imported before
#7237 and have no original_filename.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(crosspoint): page the file-name lookup, and retry a failed clipping move
From CodeRabbit's review of this PR:
- The lookup of the book imported under a file name read the user's books
in one request, and PostgREST answers at most 1000 rows (db-max-rows),
so a match past them was never found. It now pages through them by
book_hash.
- A copy was linked before its clippings moved to the library book, and a
failed move only logged a warning. Every later request followed the
link, so those clippings stayed under the copy's id for good. They now
move first, and a failed move fails that sync, leaving the copy
unlinked so the next sync tries again.
Fails without the change: "finds the book past the first 1000 imported
under a name" (no link written: expected [ …(20) ] to deeply equal
ArrayContaining{…}), and "links a copy only once its clippings have
moved, so a failed move is tried again" (expected 200 to be 500).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| volumes | ||
| .env.example | ||
| compose.build.yaml | ||
| compose.dev.yaml | ||
| compose.yaml | ||
| nginx.conf.example | ||
| README.md | ||
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_PASSWORDto a strong password (32+ chars) - update
JWT_SECRETto a random secret (32+ chars) - regenerate
ANON_KEYandSERVICE_ROLE_KEYas HS256 JWTs signed with yourJWT_SECRET(use jwt.io or a similar tool):ANON_KEYpayload:{"role": "anon"}SERVICE_ROLE_KEYpayload:{"role": "service_role"}
- set
MINIO_ROOT_PASSWORDto 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 examplev1.2.3): published from release eventsmain: rolling image from the default branchsha-<commit>: immutable commit tag
OPDS catalogs on a private network
The web OPDS proxy blocks private, loopback and link-local addresses by default,
including public hostnames that resolve to them. To reach trusted LAN catalogs,
set an exact, comma-separated allowlist in docker/.env:
READEST_TRUSTED_PRIVATE_HOSTS=books.home.arpa,calibre.lan,192.168.1.20
Recreate the client with docker compose up -d client after changing it. With
docker run, pass -e READEST_TRUSTED_PRIVATE_HOSTS=books.home.arpa instead.
This setting is read by the server at request time and works with prebuilt
images; no rebuild or NODE_ENV change is needed.
Entries are hostnames or IP addresses only, without schemes, ports, paths,
wildcards or CIDR ranges. Matching ignores case and trailing DNS dots. An entry
allows any port on that host, so only list hosts whose services you trust.
For IPv6 literals, include brackets, for example [fd00::20].
Each redirect destination must pass the same checks. List any additional private hosts used for feeds, covers or downloads. Unlisted hosts keep the private-address and DNS checks, and credentials are still removed on cross-origin redirects. The allowlist applies only to OPDS, not KOSync or Send to Readest.
Anyone who can reach your Readest instance can use its OPDS proxy to reach the
listed hosts. Keep the instance behind your LAN/VPN or access controls when
allowing private services. SELF_HOSTED=true lets the catalog form submit LAN
URLs, but does not grant server access by itself.
Build locally instead of pulling
Prerequisites for local builds: the
packages/foliate-jsandpackages/simplecc-wasmgit submodules must be initialized before building:git submodule update --init packages/foliate-js packages/simplecc-wasmIn 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 withMINIO_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.