You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I have a django app and I cannot build a docker image with django's staticfiles artifact.
Here's my dockerfile (this is just the first stage of my image, in the second stage I copy the environment)
FROM python:3.11-slim-bookworm AS builder
COPY --from=ghcr.io/astral-sh/uv:0.5 /uv /bin/
WORKDIR /myapp
# Copy app source code
...
# Create the virtual environment with myapp in itRUN uv sync --frozen --no-dev --no-cache --compile-bytecode --no-editable
# Activate the environment - we will need it for commands belowENV PATH="/myapp/.venv/bin:$PATH"# Install static filesRUN COLLECT_STATIC=True python manage.py collectstatic
# Add the static files to .venvRUN uv sync --frozen --no-dev --no-cache --compile-bytecode --no-editable
This is a pretty simple set up. Copy the app source code, run uv sync to install all the dependencies. Once that's done, I can start up my django app and collect the static files. The files are placed in the source folder. Then, I run uv sync again so that the staticfiles are copied to virtual environment. The problem is they are not.
I'm completely lost on what's going on for 2 primary reasons:
In my local dev env, I can follow this procedure and it works: uv sync, collect static files, uv sync again and the app is packaged correctly with the static files.
I can add RUN rm -rf .venv to my dockerfile before the second invocation of uv sync and the static files will be then collected correctly.
Please advise.
The text was updated successfully, but these errors were encountered:
Thanks for the issue. I think I wouldn't expect this to work either locally or in CI, because we won't re-build / re-install your project after the static files are generated. By default, we only re-build / re-install local projects if the pyproject.toml, setup.py, or setup.cfg files change -- it's similar to https://docs.astral.sh/uv/concepts/cache/#dynamic-metadata, but this is about extra content and not dynamic metadata per se.
I think you probably want --reinstall-package {project_name} in the second command.
Hi. I have a django app and I cannot build a docker image with django's staticfiles artifact.
Here's my dockerfile (this is just the first stage of my image, in the second stage I copy the environment)
This is a pretty simple set up. Copy the app source code, run
uv sync
to install all the dependencies. Once that's done, I can start up my django app and collect the static files. The files are placed in the source folder. Then, I runuv sync
again so that the staticfiles are copied to virtual environment. The problem is they are not.Here's also the relevant part in pyproject.toml
I'm completely lost on what's going on for 2 primary reasons:
RUN rm -rf .venv
to my dockerfile before the second invocation ofuv sync
and the static files will be then collected correctly.Please advise.
The text was updated successfully, but these errors were encountered: