diff --git a/.gitignore b/.gitignore index dc37ef1..982d997 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ output/ # Cache dirs .cache/ .config/ +.fontconfig/ .pytest_cache/ .ruff_cache/ diff --git a/Dockerfile b/Dockerfile index a16c400..6ac97f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -71,6 +71,18 @@ COPY --from=builder /opt/venv /opt/venv ENV PATH="/opt/venv/bin:$PATH" ENV PYTHONUNBUFFERED=1 +# Runtime caches must not land inside the bind-mounted source tree. Compose +# mounts the host repo at /app, and the container's non-root appuser cannot +# write there, so matplotlib/fontconfig logged permission errors and dropped a +# stray .fontconfig (owned by the container's uid) into the repo. Point HOME +# and the disposable caches at writable /tmp; keep the ASR model cache on the +# named volume mounted at HF_HOME (see docker-compose.yml) so it survives +# container recreates. +ENV HOME=/tmp \ + MPLCONFIGDIR=/tmp/.cache/matplotlib \ + YOLO_CONFIG_DIR=/tmp/Ultralytics \ + HF_HOME=/app/.cache/huggingface + # GPU runtime wiring — harmless no-ops on CPU builds / hosts without the # NVIDIA runtime. LD_LIBRARY_PATH points at the pip-installed CUDA libs # (paths simply don't exist in CPU images); DRIVER_CAPABILITIES asks the diff --git a/docker-compose.yml b/docker-compose.yml index 9a6fdde..57ee97d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,12 @@ services: - .:/app - /app/__pycache__ - ./output:/app/output + # Persistent, writable cache for the ASR model downloads. Without this the + # bind mount above shadows /app/.cache with a host-owned dir the non-root + # appuser cannot write (HF cache permission-denied warnings). The named + # volume is initialised from the image's appuser-owned dir, so it stays + # writable and the model survives container recreates. + - huggingface-cache:/app/.cache/huggingface restart: unless-stopped frontend: @@ -29,3 +35,6 @@ services: restart: unless-stopped depends_on: - backend + +volumes: + huggingface-cache: