FROM python:3.14-slim AS base
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 PIP_DISABLE_PIP_VERSION_CHECK=1
WORKDIR /app
COPY pyproject.toml requirements.lock ./
RUN pip install --no-cache-dir -c requirements.lock starlette 'uvicorn[standard]' asyncpg httpx cryptography pywebpush
COPY src ./src
RUN pip install --no-cache-dir --no-deps .
RUN useradd --uid 10001 --create-home nuar
USER nuar
EXPOSE 8080
CMD ["python", "-m", "nuar_backend"]

FROM base AS test
USER root
RUN pip install --no-cache-dir -c requirements.lock pytest pytest-asyncio pytest-cov ruff
COPY tests ./tests
COPY tools ./tools
CMD ["python", "-m", "pytest", "-q", "--tb=short", "--junitxml=/reports/backend.xml"]

FROM base AS runtime
