# -------------------------------------------------
# Managed by modulesync - DO NOT EDIT
# -------------------------------------------------

ARG FROM="python:3.13"
FROM ${FROM}

ARG DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=x
ENV LC_ALL=C.UTF-8
ENV UV_COMPILE_BYTECODE=0

# the base image is also built using this Dockerfile, so we have to reset this
USER root

WORKDIR /app

RUN apt-get -y update && \
    apt-get -y --no-install-recommends install pipx gettext && \
    apt-get clean && \
    find /usr/share/man /usr/share/locale /usr/share/doc -type f -delete && \
    rm -rf /var/lib/apt/lists/*

# create `app` user before `USER app`
# guarantee the uid and gid is set to 1000
RUN grep -q -w 1000 /etc/group || groupadd --gid 1000 app && \
    id -u app >/dev/null 2>&1 || useradd --gid 1000 --uid 1000 -m app && \
    chown app:app /app

USER app

ENV PATH=/home/app/.local/bin:/home/app/venv/bin:${PATH}

# the pre-commit runner is a tool, not a project dependency
RUN pipx install prek && \
    pipx upgrade prek

ENV UV_PROJECT_ENVIRONMENT=/home/app/venv
# the image ships one interpreter; a fetched one would not match production
ENV UV_PYTHON_DOWNLOADS=never
# hardlinks cannot cross the cache/venv mount boundary
ENV UV_LINK_MODE=copy

COPY pyproject.toml uv.lock ./
RUN --mount=type=secret,id=netrc,target=/home/app/.netrc,uid=1000 \
    pipx install uv && \
    pipx upgrade uv && \
    uv sync --frozen --no-install-project --all-groups && \
    uv cache clean

# *WARNING*: DO NOT "ADD . /app" because it would include the current settings in the base image

ENV DJANGO_SETTINGS_MODULE=example.settings

EXPOSE 8000
