# Use the official Python runtime image FROM python:3.13-alpine COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ # Create the app directory #RUN mkdir /app # Set the working directory inside the container WORKDIR /app # Create a non-privileged user that the app will run under. # See https://docs.docker.com/go/dockerfile-user-best-practices/ ARG UID=10001 RUN adduser \ --disabled-password \ --shell "/sbin/nologin" \ --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 ENV PYTHONUNBUFFERED=1 # Ignore pip warning about running as root ENV PIP_ROOT_USER_ACTION=ignore ## 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 # copy project settings COPY pyproject.toml uv.lock /app/ # 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 # 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 # Switch to the non-privileged user to run the application. USER appuser # Run Django’s development server CMD ["uv", "run", "manage.py", "runserver", "0.0.0.0:8000"]