The server runs as docwell (uid 10001), but a host bind mount for SERVER_DATA, or a volume created by an older image, arrives owned by root, so the search index failed with "mkdir /data/search.bleve: permission denied". The image now starts as root through a small entrypoint that chowns DOCWELL_DATA_DIR to docwell when needed, then runs docwell-server as docwell via su-exec. A container already started with a non-root user: skips the fix and runs the server directly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
683 B
Bash
21 lines
683 B
Bash
#!/bin/sh
|
|
# docwell-server entrypoint. Started as root only to make the data directory
|
|
# writable for the docwell user: a host bind mount, or a volume created by an
|
|
# older image, arrives owned by root, and the search index could not be
|
|
# written. Then it drops to docwell for good.
|
|
set -eu
|
|
|
|
DATA_DIR="${DOCWELL_DATA_DIR:-/data}"
|
|
|
|
if [ "$(id -u)" = "0" ]; then
|
|
mkdir -p "$DATA_DIR"
|
|
if [ "$(stat -c %u "$DATA_DIR")" != "10001" ]; then
|
|
echo "Fixing $DATA_DIR ownership for docwell (uid=10001)"
|
|
chown -R docwell:docwell "$DATA_DIR"
|
|
fi
|
|
exec su-exec docwell docwell-server "$@"
|
|
fi
|
|
|
|
# Already unprivileged (e.g. `user:` set in compose): run as is.
|
|
exec docwell-server "$@"
|