| 1 |
FROM python:3.13-slim AS builder |
| 2 |
|
| 3 |
RUN mkdir /src |
| 4 |
COPY . /src/ |
| 5 |
ENV VIRTUAL_ENV=/opt/venv |
| 6 |
ENV HATCH_BUILD_HOOKS_ENABLE=1 |
| 7 |
# Install build tools to compile black + dependencies |
| 8 |
RUN apt update && apt install -y build-essential git python3-dev |
| 9 |
|
| 10 |
ENV PATH="$VIRTUAL_ENV/bin:$PATH" |
| 11 |
RUN python -m venv $VIRTUAL_ENV |
| 12 |
RUN cd /src \ |
| 13 |
&& pip install --no-cache-dir --upgrade pip \ |
| 14 |
&& pip install --no-cache-dir --group hatch \ |
| 15 |
&& hatch build -t wheel \ |
| 16 |
&& pip install --no-cache-dir dist/*-cp* \ |
| 17 |
&& pip install black[colorama,d,uvloop] |
| 18 |
|
| 19 |
FROM python:3.13-slim |
| 20 |
|
| 21 |
# copy only Python packages to limit the image size |
| 22 |
COPY --from=builder /opt/venv /opt/venv |
| 23 |
ENV PATH="/opt/venv/bin:$PATH" |
| 24 |
|
| 25 |
CMD ["/opt/venv/bin/black"] |