soulsync/entrypoint.sh
Broque Thomas 77a781caba Pin yt-dlp in requirements.txt, drop pip install from entrypoint
Closes #367 (reported by JohnBaumb).

The Docker entrypoint ran `pip install -U yt-dlp --quiet --no-cache-dir`
on every container start. Three problems with that:

- Non-deterministic startup: each restart could pick up a different
  yt-dlp version, making "works on my machine" debugging harder.
- Network dependency at boot: PyPI being slow/unreachable gated the
  app coming up.
- In-place upgrades inside running containers can race with active
  yt-dlp invocations and aren't a great pattern.

Picked Option A from the issue: pin to an exact version in
requirements.txt (`yt-dlp==2026.3.17`) and remove the entrypoint
install entirely. yt-dlp comes baked into the image now via the
existing `pip install -r requirements.txt` in the Dockerfile.

Tradeoff: YouTube fixes ship via SoulSync releases now instead of
"next container restart". The pin is documented inline with how to
bump it.

Net change: -3 entrypoint lines, requirements.txt pin tightened,
WHATS_NEW '2.4.1' block opened (entries hidden until version bumps).

553 tests pass.
2026-04-26 18:02:20 -07:00

85 lines
2.8 KiB
Bash

#!/bin/bash
# SoulSync Docker Entrypoint Script
# Handles PUID/PGID/UMASK configuration for proper file permissions
set -e
# Default values
PUID=${PUID:-1000}
PGID=${PGID:-1000}
UMASK=${UMASK:-022}
echo "🐳 SoulSync Container Starting..."
echo "📝 User Configuration:"
echo " PUID: $PUID"
echo " PGID: $PGID"
echo " UMASK: $UMASK"
# Get current soulsync user/group IDs
CURRENT_UID=$(id -u soulsync)
CURRENT_GID=$(id -g soulsync)
# Only modify user/group if they differ from requested values
if [ "$CURRENT_UID" != "$PUID" ] || [ "$CURRENT_GID" != "$PGID" ]; then
echo "🔧 Adjusting user permissions..."
# Modify group ID if needed
if [ "$CURRENT_GID" != "$PGID" ]; then
echo " Changing group ID from $CURRENT_GID to $PGID"
groupmod -o -g "$PGID" soulsync
fi
# Modify user ID if needed
if [ "$CURRENT_UID" != "$PUID" ]; then
echo " Changing user ID from $CURRENT_UID to $PUID"
usermod -o -u "$PUID" soulsync
fi
# Fix ownership of app directories
echo "🔒 Fixing permissions on app directories..."
chown -R soulsync:soulsync /app/config /app/data /app/logs /app/downloads /app/Transfer /app/Staging 2>/dev/null || true
else
echo "✅ User/Group IDs already correct"
fi
# Set umask for file creation permissions
echo "🎭 Setting UMASK to $UMASK"
umask "$UMASK"
# Initialize config files if they don't exist (first-time setup)
echo "🔍 Checking for configuration files..."
if [ ! -f "/app/config/config.json" ]; then
echo " 📄 Creating default config.json..."
cp /defaults/config.json /app/config/config.json
chown soulsync:soulsync /app/config/config.json 2>/dev/null || true
else
echo " ✅ config.json already exists"
fi
# Always update settings.py — it's application code, not user configuration.
# Stale versions from older releases cause startup crashes (missing methods).
echo " 📄 Updating settings.py to current version..."
cp /defaults/settings.py /app/config/settings.py
chown soulsync:soulsync /app/config/settings.py 2>/dev/null || true
# Ensure all directories exist and have proper permissions
mkdir -p /app/config /app/data /app/logs /app/downloads /app/Transfer /app/Staging
chown -R soulsync:soulsync /app/config /app/data /app/logs /app/downloads /app/Transfer /app/Staging 2>/dev/null || true
echo "✅ Configuration initialized successfully"
# Display final user info
echo "👤 Running as:"
echo " User: $(id -u soulsync):$(id -g soulsync) ($(id -un soulsync):$(id -gn soulsync))"
echo " UMASK: $(umask)"
echo ""
echo "🚀 Starting SoulSync Web Server..."
# Execute the main command as the soulsync user
# If already running as the correct user (e.g. Podman rootless with keep-id), skip gosu
if [ "$(id -u)" = "$PUID" ]; then
exec "$@"
else
exec gosu soulsync "$@"
fi