diff --git a/Dockerfile b/Dockerfile index fe236f9..8c776f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,9 +31,12 @@ COPY . . RUN mkdir -p /app/config /app/database /app/logs /app/downloads /app/Transfer && \ chown -R soulsync:soulsync /app -# Copy example config as default config.json and set proper ownership -RUN cp /app/config/config.example.json /app/config/config.json && \ - chown soulsync:soulsync /app/config/config.json +# Create defaults directory and copy template files +# These will be used by entrypoint.sh to initialize empty volumes +RUN mkdir -p /defaults && \ + cp /app/config/config.example.json /defaults/config.json && \ + cp /app/config/settings.py /defaults/settings.py && \ + chmod 644 /defaults/config.json /defaults/settings.py # Create volume mount points VOLUME ["/app/config", "/app/database", "/app/logs", "/app/downloads", "/app/Transfer"] diff --git a/entrypoint.sh b/entrypoint.sh index fe8faf2..904bcfc 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -46,6 +46,31 @@ fi 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 +else + echo " ✅ config.json already exists" +fi + +if [ ! -f "/app/config/settings.py" ]; then + echo " 📄 Creating default settings.py..." + cp /defaults/settings.py /app/config/settings.py + chown soulsync:soulsync /app/config/settings.py +else + echo " ✅ settings.py already exists" +fi + +# Ensure all directories exist and have proper permissions +mkdir -p /app/config /app/database /app/logs /app/downloads /app/Transfer +chown -R soulsync:soulsync /app/config /app/database /app/logs /app/downloads /app/Transfer + +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))"