mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-02 20:30:10 +00:00
Add ROOTLESS_CONTAINER and request UI updates
Introduce ROOTLESS_CONTAINER env to opt out of gosu (replace /proc uid_map detection) and update entrypoint messaging; adjust app-start.sh and redis-start.sh to skip gosu when ROOTLESS_CONTAINER=true and warn on UID/GID mismatch only when applicable. Backend: include audiobook audibleAsin in admin requests response (mapped to asin) and pass baseUrl through test-flaresolverr endpoint to the FlareSolverr tester. Frontend: RecentRequestsTable and RequestActionsDropdown now surface asin, accept/passthrough annasArchiveBaseUrl, and add a "View Details" flow using AudiobookDetailsModal; admin page passes ebook baseUrl from settings. InteractiveTorrentSearchModal refactor: improved UX/UI, keyboard handling, portal/modal mounting, skeleton/loading states, formatting helpers, and richer result display. Tests updated to match changes.
This commit is contained in:
+11
-50
@@ -3,42 +3,11 @@
|
||||
# Uses gosu to ensure correct PUID:PGID for file operations
|
||||
#
|
||||
# Supports:
|
||||
# - Docker: Uses gosu to switch to PUID:PGID
|
||||
# - Rootful Podman: Uses gosu to switch to PUID:PGID (same as Docker)
|
||||
# - Rootless Podman: Skips gosu to preserve user namespace UID mapping
|
||||
# - Docker/LXC: Uses gosu to switch to PUID:PGID (default)
|
||||
# - Rootless Podman: Set ROOTLESS_CONTAINER=true to skip gosu
|
||||
|
||||
set -e
|
||||
|
||||
# =============================================================================
|
||||
# USER NAMESPACE DETECTION
|
||||
# =============================================================================
|
||||
# Detects if running in a user namespace where UID 0 is remapped to a non-root
|
||||
# user on the host (e.g., rootless Podman). In this case, using gosu would
|
||||
# cause a double-mapping that breaks volume permissions.
|
||||
#
|
||||
# How it works:
|
||||
# - /proc/self/uid_map shows the UID mapping for the current namespace
|
||||
# - Format: <uid-inside-ns> <uid-outside-ns> <range>
|
||||
# - In a normal container: "0 0 4294967295" (root maps to root)
|
||||
# - In rootless Podman: "0 1000 1" (root maps to host user 1000)
|
||||
#
|
||||
# Returns 0 (true) if in a user namespace with remapped root, 1 (false) otherwise
|
||||
# =============================================================================
|
||||
is_user_namespace_root() {
|
||||
if [ -f /proc/self/uid_map ]; then
|
||||
# Read the first mapping line (covers UID 0)
|
||||
read -r inside outside count < /proc/self/uid_map
|
||||
# Trim whitespace (uid_map has leading spaces for alignment)
|
||||
inside=$(echo "$inside" | xargs)
|
||||
outside=$(echo "$outside" | xargs)
|
||||
# If UID 0 inside maps to non-0 outside, we're in a user namespace
|
||||
if [ "$inside" = "0" ] && [ "$outside" != "0" ]; then
|
||||
return 0 # true - rootless container detected
|
||||
fi
|
||||
fi
|
||||
return 1 # false - normal container (Docker or rootful Podman)
|
||||
}
|
||||
|
||||
# Load environment from /etc/environment (set by entrypoint)
|
||||
if [ -f /etc/environment ]; then
|
||||
set -a
|
||||
@@ -58,23 +27,18 @@ cd /app
|
||||
# =============================================================================
|
||||
# START SERVER WITH APPROPRIATE UID:GID HANDLING
|
||||
# =============================================================================
|
||||
# Three scenarios:
|
||||
# 1. Docker / Rootful Podman: Running as root, use gosu to switch to PUID:PGID
|
||||
# 2. Rootless Podman: Running as "root" in user namespace, skip gosu to preserve mapping
|
||||
# 3. Non-root fallback: Already running as non-root, run directly
|
||||
# Two scenarios:
|
||||
# 1. Default: Running as root, use gosu to switch to PUID:PGID
|
||||
# 2. ROOTLESS_CONTAINER=true: Skip gosu (rootless Podman user namespace handles UID mapping)
|
||||
|
||||
start_server() {
|
||||
if [ "$(id -u)" = "0" ]; then
|
||||
if is_user_namespace_root; then
|
||||
# Rootless container (e.g., rootless Podman)
|
||||
# Skip gosu - the user namespace already maps our "root" to the correct host UID
|
||||
echo "[App] Detected rootless container (user namespace with remapped root)"
|
||||
echo "[App] Skipping gosu to preserve user namespace UID mapping"
|
||||
echo "[App] Process will run as namespace UID 0 (mapped to host user)"
|
||||
if [ "${ROOTLESS_CONTAINER}" = "true" ]; then
|
||||
# Rootless Podman: Skip gosu - user namespace already maps UID 0 to host user
|
||||
echo "[App] ROOTLESS_CONTAINER=true - skipping gosu (user namespace handles UID mapping)"
|
||||
node server.js &
|
||||
else
|
||||
# Normal container (Docker or rootful Podman)
|
||||
# Use gosu to switch to the specified PUID:PGID
|
||||
# Default: Use gosu to switch to the specified PUID:PGID
|
||||
echo "[App] Switching to UID:GID $PUID:$PGID via gosu..."
|
||||
gosu "$PUID:$PGID" node server.js &
|
||||
fi
|
||||
@@ -104,11 +68,8 @@ if [ -f "/proc/$SERVER_PID/status" ]; then
|
||||
ACTUAL_GID=$(grep '^Gid:' /proc/$SERVER_PID/status | awk '{print $2}')
|
||||
echo "[App] Verified process credentials: UID=$ACTUAL_UID GID=$ACTUAL_GID"
|
||||
|
||||
# Only warn about mismatch in non-rootless scenarios
|
||||
if ! is_user_namespace_root; then
|
||||
if [ "$ACTUAL_UID" != "$PUID" ] || [ "$ACTUAL_GID" != "$PGID" ]; then
|
||||
echo "[App] WARNING: Process UID:GID ($ACTUAL_UID:$ACTUAL_GID) does not match expected ($PUID:$PGID)"
|
||||
fi
|
||||
if [ "${ROOTLESS_CONTAINER}" != "true" ] && { [ "$ACTUAL_UID" != "$PUID" ] || [ "$ACTUAL_GID" != "$PGID" ]; }; then
|
||||
echo "[App] WARNING: Process UID:GID ($ACTUAL_UID:$ACTUAL_GID) does not match expected ($PUID:$PGID)"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -329,6 +329,7 @@ PORT=$PORT
|
||||
HOSTNAME=$HOSTNAME
|
||||
PUID=${PUID:-}
|
||||
PGID=${PGID:-}
|
||||
ROOTLESS_CONTAINER=${ROOTLESS_CONTAINER:-}
|
||||
EOF
|
||||
|
||||
echo "✅ Environment configured"
|
||||
@@ -363,7 +364,10 @@ echo "📊 Services starting:"
|
||||
echo " - PostgreSQL (internal, user=postgres)"
|
||||
echo " - Redis (internal, UID:GID=${PUID:-102}:${PGID:-102})"
|
||||
echo " - Next.js App (port 3030, UID:GID=${PUID:-1000}:${PGID:-1000})"
|
||||
if [ -n "$PUID" ] && [ -n "$PGID" ]; then
|
||||
if [ "${ROOTLESS_CONTAINER}" = "true" ]; then
|
||||
echo ""
|
||||
echo "🔐 ROOTLESS_CONTAINER=true - gosu will be skipped (user namespace handles UID mapping)"
|
||||
elif [ -n "$PUID" ] && [ -n "$PGID" ]; then
|
||||
echo ""
|
||||
echo "🔐 Using gosu for reliable UID:GID switching"
|
||||
echo " App and Redis will run as $PUID:$PGID"
|
||||
|
||||
@@ -3,42 +3,11 @@
|
||||
# Uses gosu to ensure correct PUID:PGID for file operations
|
||||
#
|
||||
# Supports:
|
||||
# - Docker: Uses gosu to switch to PUID:PGID
|
||||
# - Rootful Podman: Uses gosu to switch to PUID:PGID (same as Docker)
|
||||
# - Rootless Podman: Skips gosu to preserve user namespace UID mapping
|
||||
# - Docker/LXC: Uses gosu to switch to PUID:PGID (default)
|
||||
# - Rootless Podman: Set ROOTLESS_CONTAINER=true to skip gosu
|
||||
|
||||
set -e
|
||||
|
||||
# =============================================================================
|
||||
# USER NAMESPACE DETECTION
|
||||
# =============================================================================
|
||||
# Detects if running in a user namespace where UID 0 is remapped to a non-root
|
||||
# user on the host (e.g., rootless Podman). In this case, using gosu would
|
||||
# cause a double-mapping that breaks volume permissions.
|
||||
#
|
||||
# How it works:
|
||||
# - /proc/self/uid_map shows the UID mapping for the current namespace
|
||||
# - Format: <uid-inside-ns> <uid-outside-ns> <range>
|
||||
# - In a normal container: "0 0 4294967295" (root maps to root)
|
||||
# - In rootless Podman: "0 1000 1" (root maps to host user 1000)
|
||||
#
|
||||
# Returns 0 (true) if in a user namespace with remapped root, 1 (false) otherwise
|
||||
# =============================================================================
|
||||
is_user_namespace_root() {
|
||||
if [ -f /proc/self/uid_map ]; then
|
||||
# Read the first mapping line (covers UID 0)
|
||||
read -r inside outside count < /proc/self/uid_map
|
||||
# Trim whitespace (uid_map has leading spaces for alignment)
|
||||
inside=$(echo "$inside" | xargs)
|
||||
outside=$(echo "$outside" | xargs)
|
||||
# If UID 0 inside maps to non-0 outside, we're in a user namespace
|
||||
if [ "$inside" = "0" ] && [ "$outside" != "0" ]; then
|
||||
return 0 # true - rootless container detected
|
||||
fi
|
||||
fi
|
||||
return 1 # false - normal container (Docker or rootful Podman)
|
||||
}
|
||||
|
||||
# Load environment from /etc/environment (set by entrypoint)
|
||||
if [ -f /etc/environment ]; then
|
||||
set -a
|
||||
@@ -56,24 +25,19 @@ echo "[Redis] Process will run as UID:GID = $PUID:$PGID"
|
||||
# =============================================================================
|
||||
# START REDIS WITH APPROPRIATE UID:GID HANDLING
|
||||
# =============================================================================
|
||||
# Three scenarios:
|
||||
# 1. Docker / Rootful Podman: Running as root, use gosu to switch to PUID:PGID
|
||||
# 2. Rootless Podman: Running as "root" in user namespace, skip gosu to preserve mapping
|
||||
# 3. Non-root fallback: Already running as non-root, run directly
|
||||
# Two scenarios:
|
||||
# 1. Default: Running as root, use gosu to switch to PUID:PGID
|
||||
# 2. ROOTLESS_CONTAINER=true: Skip gosu (rootless Podman user namespace handles UID mapping)
|
||||
|
||||
REDIS_CMD="/usr/bin/redis-server --appendonly yes --dir /var/lib/redis --bind 127.0.0.1 --port 6379"
|
||||
|
||||
if [ "$(id -u)" = "0" ]; then
|
||||
if is_user_namespace_root; then
|
||||
# Rootless container (e.g., rootless Podman)
|
||||
# Skip gosu - the user namespace already maps our "root" to the correct host UID
|
||||
echo "[Redis] Detected rootless container (user namespace with remapped root)"
|
||||
echo "[Redis] Skipping gosu to preserve user namespace UID mapping"
|
||||
echo "[Redis] Process will run as namespace UID 0 (mapped to host user)"
|
||||
if [ "${ROOTLESS_CONTAINER}" = "true" ]; then
|
||||
# Rootless Podman: Skip gosu - user namespace already maps UID 0 to host user
|
||||
echo "[Redis] ROOTLESS_CONTAINER=true - skipping gosu (user namespace handles UID mapping)"
|
||||
exec $REDIS_CMD
|
||||
else
|
||||
# Normal container (Docker or rootful Podman)
|
||||
# Use gosu to switch to the specified PUID:PGID
|
||||
# Default: Use gosu to switch to the specified PUID:PGID
|
||||
echo "[Redis] Switching to UID:GID $PUID:$PGID via gosu..."
|
||||
exec gosu "$PUID:$PGID" $REDIS_CMD
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user