readest/docker
Huang Xin d5e10369b4
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/amd64, ubuntu-latest) (push) Waiting to run
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm) (push) Waiting to run
Publish Docker image / merge (push) Blocked by required conditions
Build with Nix / tests (push) Waiting to run
PR checks / koplugin_rust_lint (push) Waiting to run
PR checks / build_web_app (push) Waiting to run
PR checks / nix_flake_check (push) Waiting to run
PR checks / rust_lint (push) Waiting to run
PR checks / test_web_app (1) (push) Waiting to run
PR checks / test_web_app (2) (push) Waiting to run
PR checks / test_web_browser (push) Waiting to run
PR checks / test_extensions (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
fix(library): preserve original filenames and use PDF filename titles (#7237)
* fix(library): preserve import filenames and use PDF filename titles

Save each imported file's original basename, including its extension, on
the local Book record. Use the filename stem as the PDF display title while
preserving embedded metadata and the sourceTitle used to locate managed
files. Retain the original filename when re-importing a managed copy.

Regression evidence: before the fix, import-metahash and
import-docx-conversion had 13 assertion failures for missing
originalFilename fields and PDF titles still reading PowerPoint
Presentation. Both suites pass with the change.

Verified:
- Full unit suite: 1220 files passed, 4 skipped; 14648 tests passed,
  16 skipped (before updating to origin/main a2dd013a4).
- On origin/main a2dd013a4: six import suites plus useProgressSync,
  7 files / 124 tests passed.
- pnpm lint passed; formatting and git diff --check passed.
- Real web app: imported Device_Manual_V2.1.pdf with embedded title
  PowerPoint Presentation; filename title and originalFilename persisted
  after reload.
- Windows desktop not tested. Linux CEF verification was incomplete:
  the reused binary rendered a blank frontend in the isolated harness.

Reported by xiongshaowei on GitHub.
Refs #7230.

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

* fix(library): preserve question marks in import basenames

Derive local basenames without the URL helper's query stripping. For local
path imports use the supplied path, since NativeFile.name may already have
been shortened by that helper. Remote and provider imports retain their
resolved file names and URL fallback behavior.

The new File and path regression cases fail before this change with
originalFilename/title 'manual' instead of 'manual?rev1.pdf'/'manual?rev1'.
They now pass and verify two revisions remain separate library records.
A URL query fallback test also passes. Six import suites: 82 tests passed.
pnpm lint and formatting passed. The pre-push hook reruns the full suite.

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

* fix(library): retain filename provenance across import and sync

Keep literal POSIX backslashes in import basenames and PDF identity, while
recognizing explicit Windows paths. Strip queries only from web URL fallback
names and preserve explicitly resolved filenames.

When a cloud-restored PDF lacks its original filename, reimporting its exact
managed path preserves the stored title and metadata hash. File sync fills
missing original filenames without changing titles, storage paths, or clocks.

Verification: four importer regressions failed first (URL fallback, two
backslash input forms, and cloud-restored managed copy). Three sync assertions
failed first for missing provenance and repair detection. All 232 tests across
11 affected suites pass with the fixes. pnpm lint, Biome formatting, and git
diff --check pass. Real web imports and reload retain three distinct filename
titles, original basenames, and embedded metadata. Windows desktop was not
tested; the earlier isolated Linux CEF harness remained blank. The full suite
runs again in the pre-push hook.

Reported by xiongshaowei on GitHub.

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

* fix(library): exclude URL fragments from import fallback names

Remove the fragment before deriving the fallback name for a remote file,
while keeping explicitly resolved filenames unchanged.

Verification: the new fragment regression failed first because originalFilename
was manual.pdf#page=2 instead of manual.pdf. All 94 tests across the importer
metadata and web service suites pass, including query-plus-fragment and explicit
question-mark/hash filename cases. pnpm lint, formatting, and git diff --check
pass. Full unit tests run in the pre-push hook. Native device verification was
not repeated for this web URL fallback change.

Reported by xiongshaowei on GitHub.

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

* fix(library): decode remote basenames after parsing the URL path

Derive a web remote file's fallback name from its final pathname segment before
decoding. This excludes queries and fragments, decodes reserved characters, and
preserves encoded backslashes as filename characters. Keep the encoded spelling
when pathname bytes cannot be decoded as UTF-8. Explicit filenames bypass this.

Verification: six new URL cases failed before the fix, covering C++, a slash
inside the query, malformed query/path bytes, and two encoded backslash names.
All 100 tests in the importer metadata and web service suites now pass. pnpm
lint, Biome formatting, and git diff --check pass. The full suite runs in the
pre-push hook. Native device verification was not repeated for this web fallback.

Reported by xiongshaowei on GitHub.

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

* test(library): cover Android provider display names on import

Verify opaque Android content URIs resolve the provider display name through
Tauri basename, for both external-storage and staged-provider file paths.
Verify importBook uses that resolved File.name for originalFilename, PDF title,
and salted identity instead of parsing the document identifier.

Verification: all 114 tests across the import metadata, web service, and native
service suites pass, as do pnpm lint, formatting, and git diff --check. This is
coverage of the existing basename flow, so no production behavior changed.
Android native basename was inspected and queries OpenableColumns.DISPLAY_NAME.
UI verification could not run against the available emulator because its
existing development WebView shows an unavailable URL. The full unit suite runs
in the pre-push hook.

Reported by xiongshaowei on GitHub.

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

* fix(library): preserve resolved filenames as atomic basenames

Do not split a resolved File.name again during original filename capture.
Local path basenames were already extracted, while a decoded URL segment may
contain a slash that belongs to its filename identity.

Verification: the two-file URL regression failed first with one/part.pdf reduced
to part.pdf and a different salted hash. It now passes and verifies two live
records with distinct filename titles and metadata hashes. All 138 tests across
eight import/native suites pass. pnpm lint, formatting, and git diff --check
pass. The full suite runs in the pre-push hook. Device UI checks were not
repeated for this filename capture change.

Reported by xiongshaowei on GitHub.

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

* refactor(library): simplify import filename handling (owner: refactor and simplify it)

Replace nested filename selection with explicit URI and local-path branches.
Resolve the managed-copy title/hash exception in one block instead of spreading
it across a boolean and three ternaries. Use the resolved title directly and
avoid PDF stem processing for non-PDF imports.

Verification: this is a control-flow refactor with no intended behavior change.
All 138 tests across eight import/native suites pass both before and after.
pnpm lint, Biome formatting, and git diff --check pass. Existing regressions
cover provider names, local special characters, Windows paths, decoded URLs,
conversion, and managed-copy identity. Full tests run again in the pre-push
hook. Device UI checks were not repeated for this refactor.

Reported by xiongshaowei on GitHub.

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

* fix(library): share URL filename parsing across native and web imports

Reuse the URL pathname basename decoder in native and web filesystems. Native
URL fallbacks now exclude fragments and query separators and preserve decoded
filename characters, while explicit names remain unchanged. Use the existing
platform-aware path normalizer for managed-copy comparisons.

Verification: the new native URL and case-variant managed-copy regressions
failed before the fixes. All 146 tests across eight affected import/native
suites pass. pnpm lint, formatting, and git diff --check pass. Full tests run
in the pre-push hook. Device UI checks were not repeated; prior platform
verification limitations remain recorded on the PR.

Reported by xiongshaowei on GitHub.

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

* fix(library): keep extensionless PDF downloads distinct

Use the existing file hash as the PDF identity salt when a remote URL does
not provide a .pdf filename. Keep the query-free title and original filename.
This prevents distinct query-selected downloads with identical metadata from
replacing one another's managed files.

Verified: the new extensionless-download regression failed before the fix
(expected two live books, received one), then all 147 affected tests passed.
pnpm lint passed with one unrelated informational notice; diff check passed.
Reported by xiongshaowei on GitHub (#7230).

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

* fix(library): retain extensionless PDF identity on reimport

Select the PDF identity salt from the preserved original filename rather than
the current input URL. Extensionless imports keep content-based identity when
the same files are reopened from local managed paths.

Verified: the extended two-download regression first failed because both
metadata hashes changed to the shared download stem. The correction preserves
both hashes, original names and live records without removing managed files.
Reported by xiongshaowei on GitHub (#7230).

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

* fix(library): persist import provenance through cloud sync (owner: Can we simplify it?)

Add nullable books.original_filename, database mappings and blank-fill sync
merging so imported provenance survives cloud restoration and old clients.
Migration 031 must be applied before deploying the updated server.

Simplify PDF title/identity selection into three direct cases and normalize
the name once. Keep fallback metadata stable on managed-copy reimport and
refresh stale batch metadata keys after successful imports.

Verified: new regressions failed first for stale index keys, sanitized PDF
fallback titles, transform round trips and cloud filename merging. All 242
related tests pass, as do TypeScript, Biome lint and formatting checks. Actual
web imports, local reimports and reload preserve names and separate identities.
Migration applied twice successfully in isolated PostgreSQL, preserving null
legacy rows and round-tripping a Unicode filename. No live database changed.
Reported by xiongshaowei on GitHub (#7230).

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

* refactor(library): resolve import filenames in openFile (owner: hide the filename parsing in openFile)

Have native and web filesystem openFile return a File whose name is the resolved
basename. Keep URL and Android provider resolution at that boundary and share
literal local-path basename parsing between the filesystem implementations.
The importer now reads fileobj.name without parsing the source path again.

Verified: eight new filesystem assertions failed before the changes for full
web paths, literal POSIX backslashes, question marks and percent-encoded-looking
local or supplied names. All 252 affected tests pass, as do TypeScript and Biome
lint. Existing importer mocks now provide resolved basenames; the obsolete
empty-name filesystem fallback test was removed.
Reported by xiongshaowei on GitHub (#7230).

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

* fix(library): resolve relative Windows import basenames

Normalize native Windows separators before extracting a local basename, so
relative and drive-relative paths satisfy the openFile name contract while
POSIX backslashes remain literal.

Verified: relative and root-relative Windows regression cases failed first
with directory components in File.name. The same POSIX relative name remains
literal. All 139 filesystem/importer tests and TypeScript/Biome lint pass.
Windows UI was not exercised on this Linux host.
Reported by xiongshaowei on GitHub (#7230).

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

* fix(library): preserve PDF identity and edited titles (owner: just use the origin filename as the default title)

Use the filename stem only as the initial PDF display title. Preserve stored
PDF titles and metadata hashes on exact-file reimport, and leave existing
books without filename provenance as they are. Keep the original content
hash and new-import metadata-hash calculations, removing content-salt and
managed-copy identity migration branches and their index maintenance.

Verified: two new regressions failed first because reimport replaced edited
or legacy titles and metadata hashes. All 81 importer tests now pass; lint
and whitespace checks pass. In the real web app, importing a PDF, editing
its title through Book Details, reloading, reimporting, and reloading again
preserved the edited bookshelf title, original filename, and both hashes.
Native UI was not repeated for this title-only simplification.
Reported by xiongshaowei on GitHub (#7230).

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

* refactor(library): clarify native filename branches (owner: Why the change is so ugly?)

Resolve URL and provider names within their early-return branches, then
select the local filename. Remove the overwritten mutable filename and
nested platform/path ternary while preserving existing naming behavior.

Verified with 141 passing native/web filesystem and importer tests, plus
TypeScript, Biome lint, and git diff --check. This is a control-flow cleanup;
no behavior change or new regression test is introduced. Native UI was not
repeated for this refactor.

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

---------

Co-authored-by: Claude Code <noreply@anthropic.com>
2026-11-02 11:52:20 +01:00
..
volumes fix(library): preserve original filenames and use PDF filename titles (#7237) 2026-11-02 11:52:20 +01:00
.env.example fix(opds): allow trusted private catalogs at runtime (#7225) 2026-11-01 17:26:53 +01: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 fix(opds): allow trusted private catalogs at runtime (#7225) 2026-11-01 17:26:53 +01: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 fix(opds): allow trusted private catalogs at runtime (#7225) 2026-11-01 17:26:53 +01: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

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-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.