diff --git a/.env.example b/.env.example index 00af629..7e3cd89 100644 --- a/.env.example +++ b/.env.example @@ -28,6 +28,8 @@ PGID=1000 # Optional: Sets the default file permissions for newly created files within the container. UMASK=0022 +# Whether to setup file permissions on startup. May improve performance on remote/slow filesystems +SKIP_SET_PERMISSIONS=false ### ### Multi-user settings, disabled by default. diff --git a/docker-compose.yaml b/docker-compose.yaml index d2de779..18a57b7 100755 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,42 +2,17 @@ name: spotizerr services: spotizerr: - image: cooldockerizer93/spotizerr + image: cooldockerizer93/spotizerr:beta volumes: - ./data:/app/data - ./downloads:/app/downloads # <-- Change this for your music library dir - ./logs:/app/logs # <-- Volume for persistent logs ports: - 7171:7171 - build: - context: . - dockerfile: Dockerfile container_name: spotizerr-app restart: unless-stopped - environment: - - PUID=${PUID} # Replace with your desired user ID | Remove both if you want to run as root (not recommended, might result in unreadable files) - - PGID=${PGID} # Replace with your desired group ID | The user must have write permissions in the volume mapped to /app/downloads - - UMASK=${UMASK} # Optional: Sets the default file permissions for newly created files within the container. - - REDIS_HOST=${REDIS_HOST} - - REDIS_PORT=${REDIS_PORT} - - REDIS_DB=${REDIS_DB} - - REDIS_PASSWORD=${REDIS_PASSWORD} # Optional, Redis AUTH password. Leave empty if not using authentication - - REDIS_URL=redis://:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}/${REDIS_DB} - - REDIS_BACKEND=redis://:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}/${REDIS_DB} - - EXPLICIT_FILTER=${EXPLICIT_FILTER} # Set to true to filter out explicit content - - ENABLE_AUTH=${ENABLE_AUTH} # Set to true to enable authentication - - JWT_SECRET=${JWT_SECRET} # Set to a random string for production - - JWT_EXPIRATION_HOURS=${JWT_EXPIRATION_HOURS} # Set to 24 for 24 hours - - DEFAULT_ADMIN_USERNAME=${DEFAULT_ADMIN_USERNAME} # Set to admin - - DEFAULT_ADMIN_PASSWORD=${DEFAULT_ADMIN_PASSWORD} # Set to admin123 - - SSO_ENABLED=${SSO_ENABLED} # Set to true to enable SSO - - SSO_BASE_REDIRECT_URI=${SSO_BASE_REDIRECT_URI} # Set to http://127.0.0.1:7171/api/auth/sso/callback - - FRONTEND_URL=${FRONTEND_URL} # Frontend URL for SSO redirects - - DISABLE_REGISTRATION=${DISABLE_REGISTRATION} # Set to true to disable registration - - GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID} # Google SSO client ID - - GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET} # Google SSO client secret - - GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID} # GitHub SSO client ID - - GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET} # GitHub SSO client secret + env_file: + - .env depends_on: - redis @@ -46,11 +21,11 @@ services: image: redis:alpine container_name: spotizerr-redis restart: unless-stopped - environment: - - REDIS_PASSWORD=${REDIS_PASSWORD} + env_file: + - .env volumes: - redis-data:/data - command: redis-server --requirepass ${REDIS_PASSWORD} --appendonly yes + command: sh -c 'redis-server --requirepass "$REDIS_PASSWORD" --appendonly yes' volumes: redis-data: diff --git a/entrypoint.sh b/entrypoint.sh index 89bef06..4f9a0c4 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,3 @@ -#!/bin/bash set -e # Set umask if UMASK variable is provided @@ -6,6 +5,28 @@ if [ -n "${UMASK}" ]; then umask "${UMASK}" fi +# Compose Redis URLs from base variables if not explicitly provided +if [ -z "${REDIS_URL}" ]; then + REDIS_HOST=${REDIS_HOST:-redis} + REDIS_PORT=${REDIS_PORT:-6379} + REDIS_DB=${REDIS_DB:-0} + + if [ -n "${REDIS_PASSWORD}" ]; then + if [ -n "${REDIS_USERNAME}" ]; then + AUTH_PART="${REDIS_USERNAME}:${REDIS_PASSWORD}@" + else + AUTH_PART=":${REDIS_PASSWORD}@" + fi + else + AUTH_PART="" + fi + export REDIS_URL="redis://${AUTH_PART}${REDIS_HOST}:${REDIS_PORT}/${REDIS_DB}" +fi + +if [ -z "${REDIS_BACKEND}" ]; then + export REDIS_BACKEND="${REDIS_URL}" +fi + # Redis is now in a separate container so we don't need to start it locally echo "Using Redis at ${REDIS_URL}" @@ -50,10 +71,15 @@ else echo "Created user: ${USER_NAME} (UID: ${PUID})" fi - # Ensure proper permissions for all app directories - echo "Setting permissions for /app directories..." - chown -R "${USER_NAME}:${GROUP_NAME}" /app/downloads /app/data /app/logs || true - # Ensure Spotipy cache file exists and is writable + # Ensure proper permissions for all app directories unless skipped via env var + if [ "${SKIP_SET_PERMISSIONS}" = "true" ] || [ "${SKIP_SET_PERMISSIONS}" = "1" ]; then + echo "SKIP_SET_PERMISSIONS is set; skipping permissions for /app/downloads /app/data /app/logs" + else + echo "Setting permissions for /app directories..." + chown -R "${USER_NAME}:${GROUP_NAME}" /app/downloads /app/data /app/logs || true + fi + + # Ensure Spotipy cache file exists and is writable (fast, local to container) touch /app/.cache || true chown "${USER_NAME}:${GROUP_NAME}" /app/.cache || true