Move Docker image to hatch + compile (#3965)

This commit is contained in:
Cooper Lees 2023-10-23 08:36:47 -07:00 committed by GitHub
parent 7f1c578b89
commit d291c2338c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View File

@ -23,6 +23,8 @@
<!-- Changes to how Black is packaged, such as dependency requirements -->
- Change Dockerfile to hatch + compile black (#3965)
### Parser
<!-- Changes to the parser or to version autodetection -->

View File

@ -3,12 +3,14 @@ FROM python:3.11-slim AS builder
RUN mkdir /src
COPY . /src/
ENV VIRTUAL_ENV=/opt/venv
ENV HATCH_BUILD_HOOKS_ENABLE=1
# Install build tools to compile black + dependencies
RUN apt update && apt install -y build-essential git python3-dev
RUN python -m venv $VIRTUAL_ENV
RUN . /opt/venv/bin/activate && pip install --no-cache-dir --upgrade pip setuptools wheel \
# Install build tools to compile dependencies that don't have prebuilt wheels
&& apt update && apt install -y git build-essential \
&& cd /src \
&& pip install --no-cache-dir .[colorama,d]
RUN python -m pip install --no-cache-dir hatch hatch-fancy-pypi-readme hatch-vcs
RUN . /opt/venv/bin/activate && pip install --no-cache-dir --upgrade pip setuptools \
&& cd /src && hatch build -t wheel \
&& pip install --no-cache-dir dist/*-cp*[colorama,d,uvloop]
FROM python:3.11-slim

View File

@ -24,6 +24,8 @@ created for all unreleased
[commits on the `main` branch](https://github.com/psf/black/commits/main). This tag is
not meant to be used by external users.
From version 23.11.0 the Docker image installs a compiled black into the image.
## Usage
A permanent container doesn't have to be created to use _Black_ as a Docker image. It's