CI / lint (push) Canceled after 0s
CI / typecheck (push) Canceled after 0s
CI / unit-tests (push) Canceled after 0s
CI / integration-tests (push) Canceled after 0s
CI / container-build (push) Canceled after 0s
CI / dependency-audit (push) Canceled after 0s
Neither Dockerfile created /app/media before switching to the non-root `aurora` user, so a fresh named volume mounted there (docker-compose.yml's aurora_media_data) defaulted to root ownership -- Docker only auto-populates a volume's initial content/ownership from the image the first time it's mounted, and nothing in the image owned that path yet. The worker's first artwork download then failed with a permission error trying to mkdir a subdirectory under it. Creating and chowning /app/media to aurora before USER aurora fixes this for any volume created fresh after this build; an already-created volume from a prior `up --build` needs a one-time manual fix (`docker compose exec -u root worker chown -R aurora:aurora /app/media`) since Docker won't retroactively re-populate an existing volume. Co-Authored-By: Claude Sonnet 5 <[email protected]>
44 lines
1.7 KiB
Docker
44 lines
1.7 KiB
Docker
# syntax=docker/dockerfile:1
|
|
FROM python:3.12-slim AS base
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PIP_NO_CACHE_DIR=1
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends libpq5 \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
FROM base AS builder
|
|
RUN apt-get update \
|
|
&& apt-get install -y --no-install-recommends build-essential libpq-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
COPY pyproject.toml ./
|
|
COPY app ./app
|
|
# Editable install: site-packages ends up pointing at this /app directory by
|
|
# absolute path rather than a frozen copy of it. That matters because the
|
|
# `arq` console-script (unlike uvicorn --reload, which explicitly resolves
|
|
# its app import against the CWD) just imports whatever site-packages says
|
|
# `app` is — a non-editable install would permanently freeze the worker's
|
|
# code at whatever this build saw, silently ignoring the dev bind mount
|
|
# (docker-compose.yml's `./app:/app/app`) on every later `restart`.
|
|
RUN pip install --no-cache-dir -e .
|
|
|
|
FROM base AS runtime
|
|
RUN useradd --create-home --uid 1000 aurora
|
|
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages
|
|
COPY --from=builder /usr/local/bin /usr/local/bin
|
|
COPY app ./app
|
|
# Owned by aurora *before* the volume mount happens: Docker populates a
|
|
# fresh named volume (docker-compose.yml's aurora_media_data) from whatever
|
|
# already exists at its mount point in the image, ownership included. Skip
|
|
# this and a brand-new volume defaults to root-owned, which the non-root
|
|
# `aurora` user below can't write into.
|
|
RUN mkdir -p /app/media && chown -R aurora:aurora /app/media
|
|
|
|
USER aurora
|
|
|
|
CMD ["arq", "app.workers.worker.WorkerSettings"]
|