Something went wrong. Try again.
A free, open-source, self-hosted place to write a novel.
Something went wrong. Try again.
Fablewright docker-entrypoint.sh
12345678910111213141516171819202122232425262728293031323334353637383940#!/bin/sh# Fablewright's container entry point.## It exists so a self-hoster need not generate a signing secret or think about# migrations before starting. Everything here is idempotent, so a restart is safe.set -eu
DATA_DIR="${DATA_DIR:-/data}"
# A bind mount arrives owned by the host user, while the image runs as# `fablewright`. Start as root only long enough to make the data directory# writable, then re-run this script as the app user. The app process never runs# as root. A caller that sets `--user` skips this branch.if [ "$(id -u)" = "0" ]; then mkdir -p "$DATA_DIR/uploads" chown -R fablewright:fablewright "$DATA_DIR" exec setpriv --reuid=fablewright --regid=fablewright --init-groups "$0" "$@"fi
mkdir -p "$DATA_DIR/uploads"
# better-auth signs sessions with this secret. Generating one on first start and# keeping it beside the database means a fresh container works and an existing one# keeps its sessions across restarts.if [ -z "${BETTER_AUTH_SECRET:-}" ]; then SECRET_FILE="$DATA_DIR/auth-secret" if [ ! -s "$SECRET_FILE" ]; then echo "fablewright: generating a signing secret in $SECRET_FILE" node -e "process.stdout.write(require('node:crypto').randomBytes(48).toString('base64url'))" > "$SECRET_FILE" chmod 600 "$SECRET_FILE" fi BETTER_AUTH_SECRET="$(cat "$SECRET_FILE")" export BETTER_AUTH_SECRETfi
# The app migrates on boot, so this only reports where the database is.echo "fablewright: starting, database at ${DATABASE_URL:-$DATA_DIR/fablewright.db}"
exec "$@"