Files
tajniak81andClaude Opus 4.8 9c49a1f544 Change default PocketBase port to 8070
Set the default listen/host port to 8070 across both the rootless and
root stacks (previously 8080 rootless / 8081 root). Both internal and
external mappings derive from the same PB_PORT/PB_PORT_ROOT variables,
so a single change covers container and host.

Updated .env.example, both Dockerfiles (ENV/EXPOSE), both compose files
(env, port mapping, healthcheck), and both entrypoint fallbacks.

Note: both stacks now default to host port 8070, so they can no longer
run simultaneously without overriding PB_PORT_ROOT.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-19 16:51:56 +02:00

55 lines
1.9 KiB
Bash

#!/bin/sh
# PocketBase container entrypoint (root variant).
# Runs on every start: validates config, conditionally bootstraps the superuser,
# then execs the server. POSIX sh (busybox ash on Alpine).
set -e
DATA_DIR="/pb/pb_data"
DB_FILE="${DATA_DIR}/data.db"
PB_PORT="${PB_PORT:-8070}"
# ---- assemble global flags shared by every pocketbase invocation ----
set -- --dir="${DATA_DIR}"
if [ -n "${PB_ENCRYPTION_KEY}" ]; then
# PocketBase requires the settings-encryption key to be exactly 32 chars.
if [ "${#PB_ENCRYPTION_KEY}" -ne 32 ]; then
echo "[entrypoint] ERROR: PB_ENCRYPTION_KEY must be exactly 32 characters (got ${#PB_ENCRYPTION_KEY})." >&2
exit 1
fi
echo "[entrypoint] Settings encryption enabled."
set -- "$@" --encryptionEnv=PB_ENCRYPTION_KEY
fi
GLOBAL_FLAGS="$*"
# ---- does the requested superuser already exist? ----
superuser_exists() {
# No DB yet => first boot => cannot exist.
[ -f "${DB_FILE}" ] || return 1
count=$(sqlite3 "${DB_FILE}" \
"SELECT COUNT(*) FROM _superusers WHERE email = '${PB_ADMIN_EMAIL}';" 2>/dev/null) || return 1
[ "${count:-0}" -gt 0 ]
}
# ---- superuser bootstrap (always evaluated, before the server starts) ----
if [ -n "${PB_ADMIN_EMAIL}" ]; then
if superuser_exists; then
echo "[entrypoint] Superuser '${PB_ADMIN_EMAIL}' already exists — skipping creation."
else
if [ -z "${PB_ADMIN_PASSWORD}" ]; then
echo "[entrypoint] ERROR: superuser '${PB_ADMIN_EMAIL}' does not exist and PB_ADMIN_PASSWORD is not set." >&2
exit 1
fi
echo "[entrypoint] Creating superuser '${PB_ADMIN_EMAIL}'..."
# shellcheck disable=SC2086
/pb/pocketbase superuser create "${PB_ADMIN_EMAIL}" "${PB_ADMIN_PASSWORD}" ${GLOBAL_FLAGS}
fi
else
echo "[entrypoint] PB_ADMIN_EMAIL not set — skipping superuser bootstrap."
fi
echo "[entrypoint] Starting PocketBase on 0.0.0.0:${PB_PORT}"
# shellcheck disable=SC2086
exec /pb/pocketbase serve --http="0.0.0.0:${PB_PORT}" ${GLOBAL_FLAGS}