|
| 1 | +# Build stage: compile dependencies |
| 2 | +# Use bullseye (Debian 11) with GCC 10 instead of bookworm with GCC 12+ |
| 3 | +# rdflib-hdt 3.2 has C++ code missing #include <cstdint>, which fails on newer GCC |
| 4 | +FROM python:3.12-bullseye AS builder |
| 5 | + |
| 6 | +# Set working directory |
| 7 | +WORKDIR /app |
| 8 | + |
| 9 | +# Install uv for fast, reliable dependency management |
| 10 | +COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv |
| 11 | + |
| 12 | +# Set environment variables for uv |
| 13 | +ENV UV_COMPILE_BYTECODE=1 |
| 14 | + |
| 15 | +# Copy dependency files first for better caching |
| 16 | +COPY pyproject.toml uv.lock ./ |
| 17 | + |
| 18 | +# Install dependencies (this creates .venv with compiled packages) |
| 19 | +# --frozen ensures we use the exact versions from uv.lock |
| 20 | +# --no-dev skips development dependencies |
| 21 | +RUN uv sync --frozen --no-dev |
| 22 | + |
| 23 | +# Copy the application code |
| 24 | +COPY void_hdt/ ./void_hdt/ |
| 25 | + |
| 26 | +# Runtime stage: slim image with only runtime dependencies |
| 27 | +FROM python:3.12-slim |
| 28 | + |
| 29 | +# Set working directory |
| 30 | +WORKDIR /app |
| 31 | + |
| 32 | +# Install uv in runtime image |
| 33 | +COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv |
| 34 | + |
| 35 | +# Copy the virtual environment from builder |
| 36 | +COPY --from=builder /app/.venv /app/.venv |
| 37 | + |
| 38 | +# Copy the application code |
| 39 | +COPY --from=builder /app/void_hdt /app/void_hdt |
| 40 | + |
| 41 | +# Copy project files needed by uv |
| 42 | +COPY pyproject.toml uv.lock ./ |
| 43 | + |
| 44 | +# Set the entrypoint to use uv run (handles environment automatically) |
| 45 | +ENTRYPOINT ["uv", "run", "void-hdt"] |
| 46 | + |
| 47 | +# Default help command if no args provided |
| 48 | +CMD ["--help"] |
0 commit comments