fixed docker ffmpeg

This commit is contained in:
cool.gitter.choco
2025-03-18 12:56:45 -06:00
parent cb2b327869
commit 6c8e6d155d
3 changed files with 49 additions and 26 deletions

View File

@@ -8,7 +8,9 @@ WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
gosu \
git \
redis-server \
ffmpeg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
@@ -21,8 +23,9 @@ RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Create necessary directories
RUN mkdir -p downloads config creds
# Create necessary directories with proper permissions
RUN mkdir -p downloads config creds logs && \
chmod 777 downloads config creds logs
# Make entrypoint script executable
RUN chmod +x entrypoint.sh
@@ -30,5 +33,4 @@ RUN chmod +x entrypoint.sh
# Set entrypoint to our script
ENTRYPOINT ["/app/entrypoint.sh"]
# Default command (empty as entrypoint will handle the default behavior)
CMD []
# No CMD needed as entrypoint.sh handles application startup

View File

@@ -1,33 +1,20 @@
name: spotizerr
services:
redis:
image: redis:alpine
container_name: spotizerr-redis
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 3
spotizerr:
volumes:
- ./creds:/app/creds
- ./config:/app/config
- ./downloads:/app/downloads # <-- Change this for your music library dir
- ./logs:/app/logs # <-- Volume for persistent logs
ports:
- 7171:7171
image: cooldockerizer93/spotizerr
image: spotizerr:dev
container_name: spotizerr-app
restart: unless-stopped
depends_on:
redis:
condition: service_healthy
environment:
- PUID=1000 # Replace with your desired user ID | Remove both if you want to run as root (not recommended, might result in unreadable files)
- PGID=1000 # Replace with your desired group ID | The user must have write permissions in the volume mapped to /app/downloads
- UMASK=0022 # Optional: Sets the default file permissions for newly created files within the container.
- MAX_CONCURRENT_DL=3 # Optional: Set the number of concurrent downloads allowed
- REDIS_URL=redis://redis:6379/0
- REDIS_BACKEND=redis://redis:6379/0
- REDIS_URL=redis://localhost:6379/0
- REDIS_BACKEND=redis://localhost:6379/0

View File

@@ -6,10 +6,37 @@ if [ -n "${UMASK}" ]; then
umask "${UMASK}"
fi
# Check if Redis should be started locally
if [[ -z "${REDIS_URL}" || "${REDIS_URL}" == *"localhost"* || "${REDIS_URL}" == *"127.0.0.1"* ]]; then
echo "Starting local Redis server..."
redis-server --daemonize yes
# Wait for Redis to be ready
until redis-cli ping &>/dev/null; do
echo "Waiting for Redis to start..."
sleep 1
done
echo "Redis server is running."
# If REDIS_URL is not set, set it to localhost
if [ -z "${REDIS_URL}" ]; then
export REDIS_URL="redis://localhost:6379/0"
echo "Set REDIS_URL to ${REDIS_URL}"
fi
# If REDIS_BACKEND is not set, set it to the same as REDIS_URL
if [ -z "${REDIS_BACKEND}" ]; then
export REDIS_BACKEND="${REDIS_URL}"
echo "Set REDIS_BACKEND to ${REDIS_BACKEND}"
fi
else
echo "Using external Redis server at ${REDIS_URL}"
fi
# Check if both PUID and PGID are not set
if [ -z "${PUID}" ] && [ -z "${PGID}" ]; then
# Run as root directly
exec "$@"
echo "Running as root user (no PUID/PGID specified)"
exec python app.py
else
# Verify both PUID and PGID are set
if [ -z "${PUID}" ] || [ -z "${PGID}" ]; then
@@ -19,32 +46,39 @@ else
# Check for root user request
if [ "${PUID}" -eq 0 ] && [ "${PGID}" -eq 0 ]; then
exec "$@"
echo "Running as root user (PUID/PGID=0)"
exec python app.py
else
# Check if the group with the specified GID already exists
if getent group "${PGID}" >/dev/null; then
# If the group exists, use its name instead of creating a new one
GROUP_NAME=$(getent group "${PGID}" | cut -d: -f1)
echo "Using existing group: ${GROUP_NAME} (GID: ${PGID})"
else
# If the group doesn't exist, create it
GROUP_NAME="appgroup"
groupadd -g "${PGID}" "${GROUP_NAME}"
echo "Created group: ${GROUP_NAME} (GID: ${PGID})"
fi
# Check if the user with the specified UID already exists
if getent passwd "${PUID}" >/dev/null; then
# If the user exists, use its name instead of creating a new one
USER_NAME=$(getent passwd "${PUID}" | cut -d: -f1)
echo "Using existing user: ${USER_NAME} (UID: ${PUID})"
else
# If the user doesn't exist, create it
USER_NAME="appuser"
useradd -u "${PUID}" -g "${GROUP_NAME}" -d /app "${USER_NAME}"
echo "Created user: ${USER_NAME} (UID: ${PUID})"
fi
# Ensure proper permissions
chown -R "${USER_NAME}:${GROUP_NAME}" /app || true
# Ensure proper permissions for all app directories
echo "Setting permissions for /app directories..."
chown -R "${USER_NAME}:${GROUP_NAME}" /app/downloads /app/config /app/creds /app/logs || true
# Run as specified user
exec gosu "${USER_NAME}" "$@"
echo "Starting application as ${USER_NAME}..."
exec gosu "${USER_NAME}" python app.py
fi
fi