Skip to content

Fix/docker binary name - #514

Merged
SamTV12345 merged 4 commits into
mainfrom
fix/docker-binary-name
Nov 16, 2026
Merged

SamTV12345 merged 4 commits into
mainfrom
fix/docker-binary-name

Conversation

@SamTV12345

Copy link
Copy Markdown
Member

No description provided.

SamTV12345 and others added 3 commits November 15, 2026 14:06
The image ran the server as root. It now runs as 65532:65532, which owns
the two directories the server writes to:

- /var: the SQLite database (var/etherpad.db) and the update state, as
  before;
- /data: settings.json (ETHERPAD_SETTINGS_PATH=/data), also as saved in
  the admin UI. / is not writable for the user any more.

settings.json is read from ETHERPAD_SETTINGS_PATH when that holds one,
otherwise from the working directory as before, so a file mounted at
/settings.json keeps working. The admin UI reads the same file the
server read and saves into ETHERPAD_SETTINGS_PATH (before, it could read
and write another file than the one the server started with).
`config get` loads the settings like `config show`, instead of showing
defaults only.

A /var volume from an older image belongs to root; the README shows the
one-time chown. The kubernetes job runs the pods with runAsNonRoot and
checks the user and the writable directories.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012RMvvMtnCwj6ycD9fwLYVu
Review fixes for the unprivileged image:

- ETHERPAD_SETTINGS_FILE names settings.json (the image:
  /data/settings.json); ETHERPAD_SETTINGS_PATH stays the root (/ in the
  image), so /APIKEY.txt and relative favicon paths resolve as before.
- The read and save locations are settled once at start (Settings.
  SettingsFile/SettingsSaveFile) and used by the start and the admin UI
  alike: the UI no longer shows one file and saves another, e.g. next to
  the executable, that the next start does not read.
- Only a missing settings.json counts as missing. A file that is there but
  cannot be reached (no permission) stops the start, instead of starting
  on defaults without the configured requireAuthentication; so does a
  settings.json that does not parse (before, the server went on with
  empty settings).
- config get/show read the settings without the server's setup, so a
  query creates no database directory.
- README: a host directory bind-mounted at /var or /data keeps its owner
  and must be writable for 65532.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012RMvvMtnCwj6ycD9fwLYVu
feat(docker): run the server as an unprivileged user
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Run Docker images as non-root and align settings file handling

✨ Enhancement 🐞 Bug fix 📝 Documentation 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Run Docker images as UID 65532 with writable database and settings directories.
• Separate the settings file from the asset root, preserving legacy mounts and failing on unreadable
 files.
• Align admin and CLI configuration handling; document migration and test container permissions.
Diagram

graph TD
  IMG["Docker image"] --> USER["UID 65532"] --> RESOLVE{"Settings source"} --> DATA["/data settings"] --> LOAD["ReadConfig"] --> ADMIN["Admin UI"]
  RESOLVE --> LEGACY["Working-dir settings"] --> LOAD
  USER --> SQLITE["/var SQLite"]
  ADMIN --> DATA
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Require the designated settings file
  • ➕ Simplifies file selection and avoids a read/save path transition.
  • ➖ Breaks existing deployments that mount only /settings.json unless they migrate first.

Recommendation: Keep the fallback for existing mounts while saving to the writable designated path; it supports the non-root image without requiring every deployment to move its settings file immediately. Review the documented first-save transition carefully because the next startup will prefer the newly created file.

Files changed (13) +255 / -40

Enhancement (3) +80 / -6
DockerfileRun the primary image as an unprivileged user +14/-3

Run the primary image as an unprivileged user

• Creates user-owned /var and /data directories, sets the settings file to /data/settings.json, and runs as 65532:65532. Adds BusyBox applets needed for permission checks.

Dockerfile

Dockerfile.buildApply non-root runtime settings to the release image +14/-3

Apply non-root runtime settings to the release image

• Mirrors the writable directories, settings file location, runtime user, and BusyBox applets in the alternate image build.

Dockerfile.build

settingsfile.goResolve settings read and save paths +52/-0

Resolve settings read and save paths

• Introduces ETHERPAD_SETTINGS_FILE independently of the asset-root variable. Prefers that file, falls back to a working-directory settings.json when it is absent, and rejects other file-access errors.

lib/settings/settingsfile.go

Bug fix (4) +41 / -18
Settings.goTrack settings paths and stop on configuration errors +8/-3

Track settings paths and stop on configuration errors

• Adds untracked fields for the file read at startup and the admin save destination. Initialization now treats a configuration read error as fatal rather than continuing with defaults.

lib/settings/Settings.go

cli.goLoad file-backed settings for CLI queries +11/-1

Load file-backed settings for CLI queries

• Both config show and config get now load settings through ReadConfig and exit on read errors. CLI queries no longer run server initialization to create a database directory.

lib/settings/cli.go

viper.goLoad the selected settings file without silent fallback +11/-5

Load the selected settings file without silent fallback

• ReadConfig uses the shared file-selection rule, reports read and parse errors for the selected path, and records read/save paths on the resulting Settings.

lib/settings/viper.go

AdminMessageHandler.goAlign admin settings reads and saves with startup paths +11/-9

Align admin settings reads and saves with startup paths

• The admin UI reads the file selected at startup, or the save destination if none was read, and writes to SettingsSaveFile. Removes the path helper based on Root.

lib/ws/AdminMessageHandler.go

Tests (5) +93 / -4
build.ymlCheck non-root image permissions in CI +3/-0

Check non-root image permissions in CI

• The image smoke test verifies UID 65532, write access to /var and /data, and inability to write at the filesystem root.

.github/workflows/build.yml

settingsfile_test.goTest settings selection and unreadable-file handling +80/-0

Test settings selection and unreadable-file handling

• Covers default and designated paths, legacy fallback, precedence, and separation from the asset root. Also checks that an inaccessible file produces an error and that ReadConfig loads the selected file.

lib/settings/settingsfile_test.go

admin_message_handler_test.goUse explicit save paths in admin handler tests +3/-3

Use explicit save paths in admin handler tests

• Updates settings-save and cluster read-only tests to set and inspect SettingsSaveFile instead of deriving a file from Root.

lib/test/ws/admin_message_handler_test.go

admin_settings_file_test.goConfigure admin file tests with read and save paths +2/-1

Configure admin file tests with read and save paths

• Sets both settings file fields explicitly so the admin settings test exercises the selected file rather than the asset-root directory.

lib/test/ws/admin_settings_file_test.go

manifests.yamlEnforce non-root Kubernetes test containers +5/-0

Enforce non-root Kubernetes test containers

• Adds a container security context that requires non-root execution, disables privilege escalation, and drops capabilities.

test/kubernetes/manifests.yaml

Documentation (1) +41 / -12
README.mdDocument container commands and volume ownership +41/-12

Document container commands and volume ownership

• Documents the non-root user, writable directories, settings file precedence, and one-time ownership migration for older /var volumes. Updates Docker exec examples to use the image's etherpad-go command.

README.md

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. PDF exports lose restorable pad data ✓ Resolved
Description
The image switches to user 65532 but creates no writable /tmp, while embedEtherpadData and
ExtractEtherpadFromPdf both create temporary directories through os.MkdirTemp("", ...). In the
standard image, PDF export falls back to a file without the embedded etherpad.json attachment, and
PDF import falls back to text extraction instead of restoring the pad losslessly.


Remediation recommended

2. Admin UI shows old settings after a save ✓ Resolved
Description
The admin settings handler keeps loading the startup SettingsFile whenever it is set, while
saveSettings writes to SettingsSaveFile. In the documented Docker setup, where /settings.json
exists but /data/settings.json does not at startup, Save creates /data/settings.json but Reload
still shows the old /settings.json text until restart, so a subsequent edit and save can overwrite
the earlier changes.

Grey Divider

Tip of the day
💡 Did you know, you can choose which labels appear on a finding, and whether they show icons or text

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Review fixes for the unprivileged image:

- The image has a /tmp (1777): the PDF export attaches the pad and the
  PDF import restores it through a temporary directory. Without one the
  export dropped the attachment and the import fell back to text.
- pdfcpu no longer creates its config directory ($HOME/.config/pdfcpu):
  without a home it tried /.config, which the user may not create, and
  pdfcpu panicked in the PDF export. Attaching and extracting files need
  none of that configuration.
- The admin UI loads the file saves go to, and the file the server
  started with only while nothing was saved: a reload after a save shows
  what was saved, not the mounted /settings.json, so a second save cannot
  undo the first.

The PDF layout test now also checks that the pad is attached and the
link annotation survives attaching it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012RMvvMtnCwj6ycD9fwLYVu
@SamTV12345
SamTV12345 merged commit e2b3416 into main Nov 16, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant