Follow-up to the poll fix, covering the two things that blocked a
successful end-to-end album import once the poll itself stopped
freezing:
1. Staging dir permissions
The album-bundle private staging path defaults to
'storage/album_bundle_staging' -> /app/storage, but /app/storage was
never created or chowned by the image (unlike /app/Staging,
/app/Transfer, etc.), and /app is root-owned. The copy failed with
"[Errno 13] Permission denied: 'storage'" under the non-root soulsync
UID. Added /app/storage to the Dockerfile build-time mkdir+chown and
the entrypoint PUID/PGID chown, exactly like the sibling runtime dirs.
2. Client->local path resolution
Usenet/torrent clients report save paths from inside THEIR OWN
container (e.g. SAB '/data/downloads/music/<album>'); SoulSync often
mounts the same files at a different point ('/app/downloads/<album>').
Feeding the client path straight to the audio walker yields
"No audio files found" though the files are physically present.
New resolve_reported_save_path():
a. use the reported path as-is if readable (mirrored mounts),
b. apply explicit download_source.usenet_path_mappings
({from,to}, Sonarr/Radarr-style) for non-shared layouts,
c. basename fallback under SoulSync's own download roots —
zero-config for the standard shared-volume arr setup.
Wired into both call sites in usenet.py AND torrent.py
(download_album_to_staging + _finalize_download), logging any
translation and including the resolved path in the no-audio error.
Tests: resolver verbatim / explicit-mapping / basename-fallback /
priority / not-found / empty / mapping-miss-then-basename. ruff +
compileall + pytest green (645 in the download suites).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
127 lines
5 KiB
Docker
127 lines
5 KiB
Docker
# SoulSync WebUI Dockerfile
|
|
# Multi-architecture support for AMD64 and ARM64
|
|
|
|
FROM node:24-slim AS webui-builder
|
|
|
|
WORKDIR /app/webui
|
|
|
|
COPY webui/package.json webui/package-lock.json ./
|
|
RUN npm ci
|
|
|
|
COPY webui/ ./
|
|
RUN npm run build
|
|
|
|
# Stage 1: Builder — install Python dependencies with compilation tools
|
|
FROM python:3.11-slim AS builder
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
gcc \
|
|
libc6-dev \
|
|
libffi-dev \
|
|
libssl-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create virtualenv and install dependencies
|
|
RUN python -m venv /opt/venv
|
|
ENV PATH="/opt/venv/bin:$PATH"
|
|
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir --upgrade pip && \
|
|
pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Stage 2: Runtime — only runtime dependencies, no build tools
|
|
FROM python:3.11-slim
|
|
|
|
# Build-time commit SHA for update detection
|
|
ARG COMMIT_SHA=""
|
|
ENV SOULSYNC_COMMIT_SHA=${COMMIT_SHA}
|
|
|
|
# Copy pre-built virtualenv from builder
|
|
COPY --from=builder /opt/venv /opt/venv
|
|
ENV VIRTUAL_ENV=/opt/venv
|
|
ENV PATH="/opt/venv/bin:$PATH"
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Install runtime-only system dependencies (no gcc/build tools)
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
curl \
|
|
gosu \
|
|
ffmpeg \
|
|
libchromaprint-tools \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create non-root user for security
|
|
RUN useradd --create-home --shell /bin/bash --uid 1000 soulsync
|
|
|
|
# Copy application code with ownership baked in.
|
|
# Using `COPY --chown` instead of `COPY` + `chown -R /app` avoids an
|
|
# extra image layer that duplicates the entire /app tree just to flip
|
|
# ownership bits — Docker layers are immutable, so chown -R rewrites
|
|
# every file into a new layer. On a clean repo that's small; if any
|
|
# bulky workspace file slips in (e.g. auto-downloaded ffmpeg binaries
|
|
# in tools/), it gets counted twice in the image. Cin caught this on
|
|
# 2026-05-08 — see the .dockerignore comment for the same incident.
|
|
COPY --chown=soulsync:soulsync . .
|
|
COPY --chown=soulsync:soulsync --from=webui-builder /app/webui/static/dist /app/webui/static/dist
|
|
|
|
# Create runtime mount-point directories the app expects to exist.
|
|
# NOTE: /app/data is for database FILES, /app/database is the Python package
|
|
# NOTE: /app/Staging is required even though most users bind-mount it —
|
|
# the entrypoint mkdir runs early and is gated by `set -e`, so a missing
|
|
# pre-baked directory would crash the container into a restart loop on
|
|
# rootless Docker/Podman where in-container "root" can't write to /app.
|
|
# Pre-baking the dir here makes the entrypoint mkdir a guaranteed no-op.
|
|
# NOTE: /app/Stream is the transient single-file streaming cache used by
|
|
# the basic-search "Play" flow (cleared per use, never persistent). It's
|
|
# created lazily by `core/streaming/prepare.py` via `os.makedirs`, which
|
|
# fails silently on rootless Docker where the soulsync UID can't write
|
|
# to /app — playback then errors out with no obvious cause. Pre-baking
|
|
# at build time (when the layer is owned by root) avoids that path.
|
|
# NOTE: /app/storage is the PRIVATE album-bundle staging area for the
|
|
# torrent / usenet whole-release flow (download_source.album_bundle_staging_path
|
|
# defaults to 'storage/album_bundle_staging'). Like /app/Stream it's created
|
|
# lazily at runtime via mkdir(parents=True); without pre-baking it owned by
|
|
# soulsync, the album-bundle copy fails with "[Errno 13] Permission denied:
|
|
# 'storage'" because /app itself is root-owned and the soulsync UID can't
|
|
# create a top-level dir there.
|
|
RUN mkdir -p /app/config /app/data /app/logs /app/downloads /app/Transfer /app/Staging /app/Stream /app/storage /app/MusicVideos /app/scripts && \
|
|
chown soulsync:soulsync /app/config /app/data /app/logs /app/downloads /app/Transfer /app/Staging /app/Stream /app/storage /app/MusicVideos /app/scripts
|
|
|
|
# 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
|
|
# NOTE: Changed /app/database to /app/data to avoid overwriting Python package
|
|
VOLUME ["/app/config", "/app/data", "/app/logs", "/app/downloads", "/app/Transfer", "/app/MusicVideos", "/app/scripts"]
|
|
|
|
# Copy and set up entrypoint script
|
|
COPY entrypoint.sh /entrypoint.sh
|
|
RUN chmod +x /entrypoint.sh
|
|
|
|
# Note: Don't switch to soulsync user yet - entrypoint needs root to change UIDs
|
|
# The entrypoint script will switch to soulsync after setting up permissions
|
|
|
|
# Expose port
|
|
EXPOSE 8008
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
|
CMD curl -f http://localhost:8008/ || exit 1
|
|
|
|
# Set environment variables
|
|
ENV PYTHONPATH=/app
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV DATABASE_PATH=/app/data/music_library.db
|
|
ENV PUID=1000
|
|
ENV PGID=1000
|
|
ENV UMASK=022
|
|
|
|
# Set entrypoint and default command
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
|
CMD ["gunicorn", "-c", "gunicorn.conf.py", "wsgi:application"]
|