readest/docker
Huang Xin 60aac44770
Some checks are pending
CodeQL Advanced / CodeQL gate (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Blocked by required conditions
CodeQL Advanced / Analyze (javascript-typescript) (push) Blocked by required conditions
CodeQL Advanced / Analyze (python) (push) Blocked by required conditions
CodeQL Advanced / Analyze (rust) (push) Blocked by required conditions
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 / CI gate (push) Waiting to run
PR checks / nix_flake_check (push) Blocked by required conditions
PR checks / rust_lint (push) Blocked by required conditions
PR checks / koplugin_rust_lint (push) Blocked by required conditions
PR checks / build_web_app (push) Blocked by required conditions
PR checks / test_web_app (1) (push) Blocked by required conditions
PR checks / test_web_app (2) (push) Blocked by required conditions
PR checks / test_web_browser (push) Blocked by required conditions
PR checks / test_extensions (push) Blocked by required conditions
PR checks / build_tauri_app (push) Blocked by required conditions
Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
Deploy to vercel on merge / build_and_deploy (push) Waiting to run
feat(stats): reading speed by language over time, synced across devices (#8023) (#8070)
* feat(stats): reading speed by language over time (#8023)

Reading speed was kept per unit (words, characters) for today and all
time only. Speed samples now record the language they were counted in,
the section's lang or else the book's, and Reading Statistics shows:

- a Reading Speed section with each language's average, its change this
  month against last month, and a 12-week trend;
- a Reading Speed page per language: a Week/Month/Year line chart with
  the period's average and its change from the period before, the
  selected day or month with its measured reading time, today/this
  week/this month/highest monthly average, and each book's speed.

The layout follows the reporter's mockup, with the dialog's existing
pieces (boxed lists, the reading time chart's range control and period
arrows). A migration adds `lang` to readest_reading_speed; samples from
before it show under Unknown. Speed samples still stay on the device:
syncing them needs a server table and is left for its own change.

Tests: readingSpeedStats (new) covers grouping by language, local days,
week/year points and period change; statisticsDb covers the migration
on a v0.12.26 database and the two new queries; readingSpeed and
ReadingStatsTracker cover the recorded language; ReadingStats covers the
section and the page (change this month, overview, books, arrow keys,
switching language). Without the change they fail: without the
migration the statisticsDb cases fail with "no such column: lang";
without recording the language the tracker cases fail on the missing
lang ('expected { unit: 'words', count: 80, ... } to match object
{ unit: 'words', lang: 'en' }'); without the dialog wiring the two
ReadingStats cases find no "Englisch" row. 164 tests in the statistics
and stats suites, the calendar browser test (16), lint and format pass.

Verified on dev-web (Chromium, Galaxy S8 360px and 1280px desktop) with
real page turns in an English and a Chinese EPUB on dates from Sep to
Nov: light, dark, e-ink, Arabic RTL, German; tapping chart points.
On the Linux CEF desktop app (native Turso), a statistics.db built at
the v0.12.26 schema with two speed samples migrated to user_version 3,
kept both rows with lang '' (shown as Unknown, 275 words/min), and three
real page turns in Alice were stored as 'en' at 208-221 words/min and
shown as English, 217 words/min.

Reported by Zack9476 on GitHub.

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

* fix(stats): reading speed review fixes from CodeRabbit (#8023)

Five findings from CodeRabbit on #8070:

- Reading Speed by Book joined speed samples to book rows by md5, and a
  KOReader book table can hold two rows of one md5 (keyed on title,
  authors and md5), so such a book's words and time were counted twice.
  It now joins the first row of each md5.
- The 12-week trend dropped weeks without a speed before drawing, so a
  gap of ten weeks looked like a gap of one. Each week keeps its place.
- Language rows were as tall as their content, so a row with the "this
  month" line was taller than one without. Rows are min-h-14 like the
  other boxed-list rows.
- The Details link's tap area was its 19px line. It takes touch-target.
- Speeds from before languages were recorded can be in words and in
  characters, and the picker showed both as "Unknown". Those options now
  name their unit.

Tests: statisticsDb "counts a book's speed once when the book has two
metadata rows" failed with count 120 instead of 60; ReadingStats "spaces
the trend by week" failed with x 0/50/100 instead of 0/9/100; "tells
apart languages that were not recorded" failed with two "Unknown"
options. All pass now, with the 167 tests of the statistics and stats
suites, lint and format. The by-book query returns one row per book on
Turso 0.6.0-pre.9 (the native plugin's version) and 0.6.0-pre.28.

In dev-web at 360px: both language rows measure 56px with and without
the change line; the Details link answers taps 16px above and below its
centre (44px target); Reading Speed by Book still lists the book.

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

* fix(settings): keep sub-page breadcrumbs on one line (owner: Layout for smaller screen, wrapped lines at header is strange)

On a phone, "Reading Statistics › Reading Speed" did not fit: the parent
crumb wrapped onto two lines and the page name was cut ("Reading
Spe…"). Reading Calendar and Statistics by Book did the same, and so did
Settings sub-pages with a long parent ("Custom Translators › Add
Translator" in English, more in longer languages).

Now only the parent shrinks, on one line with an ellipsis, so the page
you are on keeps its full name. The name is cut only when it would leave
the parent less than a 1.5em stub, and the crumb row fills the header
so the cap measures the room the row really has.

Tests: a 360px browser test opens the three statistics sub-pages in en,
de, el, ka and ta and checks the parent stays on one line and the page
name is cut only once the parent is down to its stub. On the old header
it fails in all five: en, el, ka and ta with "expected 2 to be 1" (the
parent took two lines), de with "expected 105 to be 27" (the name was
cut while the parent kept 105px). The statistics and Settings sub-page
suites (64) and the browser file (21) pass; lint (tsc + biome) passes
apart from a warning in a file this change doesn't touch.

Checked against the old header on every Settings breadcrumb (30 pairs)
in en, de, fr and ka at 296px (phone) and 520px (desktop dialog): 172
of 240 render identically, all desktop ones among them; 53 now show the
page name in full where the parent wrapped or the name was cut; 15 are
still cut, never shorter than before; none wraps. On dev-web at 360px
(Galaxy S8) the three statistics sub-pages are one line in English,
German, French and Arabic.

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

* fix(settings): keep the breadcrumb's back target large when it shrinks

Since the parent crumb gives up its width first, it can shrink to its
1.5em stub (27px), and its hit area shrank with it. The button now
carries touch-target, which grows the hit area to 44px without
widening what you see, and the label is cut inside the button: the
clip used to sit on the button itself and would have cut the larger hit
area too. Raised by CodeRabbit on #8070.

Tests: the 360px breadcrumb browser test now taps 4px below the parent
crumb and, at its stub, 6px to its left; both reach the crumb. On the
previous header it fails in all five locales ("expected false to be
true" at the tap below). The browser file (21), the statistics and
Settings sub-page suites (64) and lint pass. On dev-web at 360px the
breadcrumb band of all three statistics sub-pages is pixel-identical
to before.

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

* feat(sync): sync reading speed across devices (#8023)

Reading speed stayed on the device that measured it, so each device
showed only its own languages and history. It now syncs through
Readest Cloud like the page events, behind the same stats sync switch.

A device pushes one row per book, language and unit for each quarter
hour it read in, keyed by its first sample there: about four rows per
hour of reading instead of one per page, so the server table needs no
archive. Two devices never share a key, and a row only grows while its
quarter hour lasts, so the server keeps the longer copy. Pulled rows
are kept apart from this device's own samples (a `remote` flag), so a
device's own row coming back meets its first sample's key and is
ignored. Deleting a book's statistics deletes its speed on every
device: the pull flags rows that started before the book's deleted_at.
Merging moves the source's speed, its own and pulled, to the target.
A server without speed sync still syncs and merges the pages.

Server: migration 036 adds stat_speeds with RLS and the
upsert_stat_speeds merge RPC; /api/sync/speeds pages its pull on the
(updated_at, book_hash, start_time_ms) keyset. Deploy both before
releasing clients that push speed.

Tests: speedSync covers the push (one row per quarter hour, sent again
only when it grows, pulled rows never sent back), the pull (counted
once, own rows and deleted books skipped, keyset paging, a minute of
overlap) and the merge; sync-speeds covers the route; ReadingStats
covers the dialog's pull. Removing each behavior fails its test on an
assertion: without the echo guard the totals read count 340 for 270,
without skipping deleted rows 370 for 270; pushing pulled rows changes
the pushed rows; without the changed-quarter check the push runs twice
for once; without the merge push "expected to be called with
arguments"; without the route's flag ['x', 1000, false] for true;
without the dialog's pull "expected to be called at least once". The
related suites (53 files, 641 tests), lint and format pass. The new
local SQL gives the same results on Turso 0.6.0-pre.9 (native app) and
0.6.0-pre.28.

Verified end to end on a self-hosted Supabase (repo migrations, 036
applied) with dev-web and three browser profiles on one account. Device
A, holding Sep-Nov history, pushed 10 rows; a fresh device B then showed
the same English 180 words/min and Chinese 249 characters/min as A.
After B read three pages of Alice, both showed English 203 words/min
(+25.5% this month), matching the server's sum. After Alice's
statistics were deleted, A and a newly signed-in device C showed only
Chinese.

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

* fix(sync): order the speed pull after pages, keep merges retryable

From CodeRabbit's review of #8070:

- The reader started the page pull and the speed pull together. Speed
  fetched just before another device deleted a book could be applied
  after the page pull removed it, bringing its rows back. The speed
  pull now starts once the page pull settles, as the dialog already did.
- A merge carried on after any failure to move the speed, then deleted
  the source on the server, so speed this device had already pushed
  never reached other devices under the target. Only a server without
  speed sync lets it carry on now; any other failure stops before the
  deletion, so the merge can be retried. SyncClient tells the two apart:
  a 404 (no /api/sync/speeds) reads as "no speed sync" (null / false)
  instead of an error, which also stops the reader warning on every
  push against such a server.
- The push route read fields of a null row and failed the batch with a
  500; it now rejects that row and stores the rest.
- The pull test's leftover empty response was consumed by its second
  pull, so the shorter-row check never ran. It runs now: without the
  longer-wins rule it fails with count 130 for 270.

Tests: before the fix the new ReadingStatsTracker case failed with
"expected not to be called at all, but actually been called 1 times"
(speed pulled while the page pull was pending); the merge case with
"promise resolved undefined instead of rejecting"; the client case
threw "Failed to pull speeds" on a 404; the push-cursor case with
"expected 1800000001000 to be +0"; the route case with "Cannot read
properties of null". The related suites (55 files, 651 tests), lint
and format pass.

On the self-hosted stack with dev-web: device B read three pages of the
Chinese book; the server log shows its stats pull, then its speed pull,
then three speed pushes; device A then showed the server's total, 276
characters/min. With the route removed (404), A's statistics still
showed its local speed, and the app logged no speed warning.

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

* feat(sync): carry reading speed in page events' ext (owner: Can we sync the raw data, and make every device calculate the speed?)

Replaces the stat_speeds table and /api/sync/speeds route from 119bf2801
and b08db6c10. Reading speed now syncs with the page events it was read in,
so no server change is needed.

- A speed sample waits for the next page event the tracker saves. The page
  turn that ends a sample also saves that page, so the sample goes with it.
  When an idle pause has already saved the page, the next page carries it.
  The event keeps the samples summed per language and unit as
  `{ speed: [{ lang, unit, count, durationMs }] }`.
- Locally, the event's ext goes in the existing readest_page_ext table. The
  speed queries read rows built from it, starting where the event starts.
  Every device builds them the same way for every event it holds, so a
  device's own events coming back from the server meet the same keys and
  change nothing. That removes the remote flag, the speed cursors and the
  dedup guard.
- Push sends ext with each event. /api/sync already stores and returns it,
  and the archive keeps it. Pull reads it, dropping entries it can't
  read. Merges carry ext under the target, and deletions remove it.
- Speed saved before this change stays on its device, and is still merged
  and deleted with its book.

Verified:
- New and converted tests fail without the change, each on an assertion,
  e.g. pageSpeedSync "expected null to deeply equal { speed: [...] }" and
  ReadingStatsTracker "expected [] to deeply equal [[{ lang: 'en', ... }]]"
  (12 failing tests across 5 files); all pass with it.
- 828 tests in the 93 related files (statistics, stats components,
  api routes, libs, database) and pnpm lint pass.
- dev-web on a local self-hosted Supabase whose schema is main's
  (stat_speeds dropped), two fresh browser devices on one account. The
  server rows carry each page's speed in ext. Both devices show English
  398 words/min and Chinese 454 characters/min, the totals of those rows.
  After the second device read more English, both show the combined 327
  words/min. The first device's own events coming back left its numbers
  unchanged.
- Not run: the Tauri app (native Turso). The SQL ran on the Node build
  (tests) and the web WASM build (dev-web).

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

* fix(sync): date page-event speed by its first sample, read events with it

From CodeRabbit's review of 2d91afea8:

- A page event's speed now keeps the start of its first sample, per
  language and unit (`startTimeMs` in ext), and its rows are dated by it.
  A sample that a later page carries after an idle pause stays on the day
  and quarter hour it was read in. Keyed by that millisecond, two pages of
  a book that start in the same second no longer share a key and drop one
  page's speed.
- The push read and the merge push's read of a book's events take the
  write lock. An event and its speed are saved in two statements, and a
  push that read the event alone moved its cursor past the speed.
- Backups write the page events as they are, so they now carry speed
  too. Applying events from another device or a backup keeps only the
  speed this version can read: an entry the table rejects would roll back
  the whole statistics restore.

Verified:
- Each new test fails without its fix on an assertion: "expected [] to
  deeply equal [ { startTimeMs: 86280000, ... } ]" (dated by the carrier),
  "count: 30 to deeply equal count: 60" (same-second pages), "expected
  [ undefined ] to deeply equal [ [ { lang: 'en', ... } ] ]" (push and merge
  reads), "promise rejected ... CHECK constraint failed ... instead of
  resolving" (unreadable speed from a backup). The tracker test fails on
  the missing sample start.
- 6692 tests in 505 files (statistics, components/stats, pages/api, libs,
  services) and pnpm lint pass.
- dev-web on the self-hosted stack with main's server schema, new account,
  two fresh devices: the server rows carry startTimeMs; both devices show
  English 388 words/min, the total of those rows.

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

* fix(sync): keep each speed sample a page event carries

From CodeRabbit's follow-up on 3bc452b5b: summing a page's samples per
language and unit dated the sum by its first sample. When a page carried a
sample from before an idle pause along with its own, the second sample
took the first one's start and could land on the day before. A page
carries one to three samples, so ext now holds each one as it is, with
its own start, and sumPageSpeed goes. Each speed row is one sample again,
as in the table since it shipped.

Verified:
- New tracker test "keeps each sample a page carries, with its own
  start" (page 2 carries page 1's sample from before midnight and its own
  from after) fails without the change: "expected [ [ { lang: 'en', …(4) }
  ] ] to deeply equal [ [ { lang: 'en', …(4) }, …(1) ] ]".
- 176 tests in statistics and components/stats, and pnpm lint, pass.
- dev-web on the self-hosted stack, same account as before: the
  Chinese pages each carry their sample in ext. The second device shows
  Chinese 413 characters/min and English 388 words/min, the server's
  totals.

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

* fix(stats): name speed with no language when showing it (owner: Can the language fill process be defered when displaying the speed data instead of in the migration process, so that it could be safer?)

Speed saved before languages were recorded (v0.12.26) has no language, so
Reading Statistics listed it under Unknown. It now shows it in its book's
language from the library, else in the app's interface language, when that
language is counted in the same unit (words or characters). Otherwise it
stays Unknown. This answers "Can we fill the lang column from the library
book row data (with the current system language as fallback) when migrating
instead of using the Unknown data?", but only when showing: the migration and
the saved rows are unchanged, and nothing is written back. Speed quarters are
read per book so each can be named. If the library can't be read, the speed
shows under Unknown as before.

Tests that fail without it (run against stubs, then the change):
- readingSpeed guessSpeedLanguage: expected '' to be 'fr'.
- readingSpeedStats nameSpeedLanguages: expected [['m1', '', 'words'], ...]
  to deeply equal [['m1', 'fr', 'words'], ...].
- statisticsDb per-book quarters: expected [{ quarter: 1, lang: '', ... }] to
  deeply equal [{ quarter: 1, md5: 'old', ... }].
- ReadingStats dialog: expected 'Französisch100 words/min' to contain
  '200 words/min', and the library read from disk: expected "vi.fn()" to be
  called at least once.
- Without the fallback when the library can't be read: expected null not to
  be null (no Unknown row).

Verified:
- statistics and components/stats: 16 files, 181 tests pass. pnpm lint
  passes; Biome format is clean.
- Linux CEF desktop app (native Turso): a v0.12.26 statistics.db with speed
  for a library book (English), a removed book counted in words and one
  counted in characters, with the app in German. Reading Statistics showed
  Englisch 250 words/min, Deutsch 300 words/min and Unbekannt 400
  characters/min, and the English page listed the library book. The three
  saved rows still had lang '' afterwards.
- dev-web (WASM): a profile from the earlier end-to-end run still shows
  English 388 words/min and Chinese 413 characters/min.

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

* fix(sync): keep a page event's ext when a longer copy has none (owner: add the COALESCE hardening to the server migration)

upsert_stat_pages and upsert_stat_pages_as replace a stat_pages row when the
same event arrives with a strictly longer duration, and replaced its ext
with whatever the copy carried. KOReader and older app versions push events
without ext, so such a copy would drop the reading speed a Readest device
saved in it. Migration 036 keeps the stored ext when the incoming copy has
none; a copy with its own ext still replaces it. Nothing else changes: each
function is 019's / 020's with only the ext line changed.

Test that fails without it: scripts/db/verify-migration-036.sh, on
PostgreSQL 15 (supabase/postgres:15.8.1.085). With 036 re-creating both
functions under the old rule it fails with "ERROR: upsert_stat_pages keeps
ext a longer copy lacks"; with only upsert_stat_pages changed, with
"ERROR: upsert_stat_pages_as keeps ext a longer copy lacks". With the change:
"ALL MIGRATION 036 CHECKS PASSED".

Also run:
- verify-migration-020.sh with 036 applied after 021: all checks pass,
  including the upsert_stat_pages_as merge and that anon/authenticated still
  can't execute it.
- statistics, components/stats, docker, libs, pages/api suites: 95 files,
  850 tests pass. pnpm lint passes.
- Not run: applying 036 to the production database.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 07:57:49 +01:00
..
volumes feat(stats): reading speed by language over time, synced across devices (#8023) (#8070) 2026-11-29 07:57:49 +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.