Moved to uv packaging

This commit is contained in:
2026-04-14 13:02:01 +02:00
parent a953bce90e
commit b4f39381e3
4 changed files with 91 additions and 36 deletions
+27 -33
View File
@@ -1,12 +1,12 @@
# Use the official Python runtime image
FROM python:3.13-alpine
#COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# Disable development dependencies
#ENV UV_NO_DEV=1
# Create the app directory
RUN mkdir /app
#RUN mkdir /app
# Set the working directory inside the container
WORKDIR /app
# Create a non-privileged user that the app will run under.
@@ -14,14 +14,17 @@ RUN mkdir /app
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser
# Set environment variables
## Django
# Allow all hosts
ENV DJANGO_ALLOWED_HOSTS=*
## Python
# Prevents Python from writing pyc files to disk
ENV PYTHONDONTWRITEBYTECODE=1
# Prevents Python from buffering stdout and stderr
@@ -29,43 +32,34 @@ ENV PYTHONUNBUFFERED=1
# Ignore pip warning about running as root
ENV PIP_ROOT_USER_ACTION=ignore
# Upgrade pip
#RUN pip install --upgrade pip
## uv
# Enable bytecode compilation
ENV UV_COMPILE_BYTECODE=1
# Copy from the cache instead of linking since it's a mounted volume
ENV UV_LINK_MODE=copy
# Disable development dependencies
ENV UV_NO_DEV=1
# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds.
# Leverage a bind mount to requirements.txt to avoid having to copy them into
# into this layer.
# using pip (uv is below)
# copy project settings
COPY pyproject.toml uv.lock /app/
RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=bind,source=requirements.txt,target=/requirements.txt \
python -m pip install -r /requirements.txt
## run this command to install all dependencies
#RUN pip install --no-cache-dir -r requirements.txt
##RUN pip install --no-cache-dir django-tailwind
# Install the project's dependencies using the lockfile and settings
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --locked --no-install-project
RUN chown appuser:appuser /app
# Switch to the non-privileged user to run the application.
USER appuser
# allow all hosts
ENV DJANGO_ALLOWED_HOSTS=*
# Copy the Django project files to the container
COPY --chown=appuser:appuser excel_mimic /app/excel_mimic
COPY --chown=appuser:appuser sheets /app/sheets
COPY --chown=appuser:appuser manage.py db.sqlite3 /app/
# Expose the Django port
EXPOSE 8000
# Set the working directory inside the container
WORKDIR /app
#RUN uv sync --locked
# Switch to the non-privileged user to run the application.
USER appuser
# Run Djangos development server
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
CMD ["uv", "run", "manage.py", "runserver", "0.0.0.0:8000"]