# Use a Python image with uv pre-installed FROM ghcr.io/astral-sh/uv:python3.12-alpine AS builder # Set the working directory WORKDIR /app # Enable bytecode compilation ENV UV_COMPILE_BYTECODE=1 # Copy from the cache instead of linking ENV UV_LINK_MODE=copy # Install dependencies RUN --mount=type=cache,target=/root/.cache/uv \ --mount=type=bind,source=uv.lock,target=uv.lock \ --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ uv sync --frozen --no-install-project --no-dev # Final image FROM python:3.12-alpine # Create a non-privileged user RUN adduser --disabled-password --gecos "" appuser WORKDIR /app # Copy the virtualenv from the builder COPY --from=builder --chown=appuser:appuser /app/.venv /app/.venv # Set environment variables ENV PATH="/app/.venv/bin:$PATH" ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 ENV DJANGO_ALLOWED_HOSTS=* # Copy the application code COPY --chown=appuser:appuser . . # Switch to the non-privileged user USER appuser # Run the Django app # The Django project root is at /app/isotables/ WORKDIR /app/isotables EXPOSE 8000 CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]