Skip to content

Commit d291c23

Browse files
authored
Move Docker image to hatch + compile (#3965)
1 parent 7f1c578 commit d291c23

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
<!-- Changes to how Black is packaged, such as dependency requirements -->
2525

26+
- Change Dockerfile to hatch + compile black (#3965)
27+
2628
### Parser
2729

2830
<!-- Changes to the parser or to version autodetection -->

Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ FROM python:3.11-slim AS builder
33
RUN mkdir /src
44
COPY . /src/
55
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
69
RUN python -m venv $VIRTUAL_ENV
7-
RUN . /opt/venv/bin/activate && pip install --no-cache-dir --upgrade pip setuptools wheel \
8-
# Install build tools to compile dependencies that don't have prebuilt wheels
9-
&& apt update && apt install -y git build-essential \
10-
&& cd /src \
11-
&& pip install --no-cache-dir .[colorama,d]
10+
RUN python -m pip install --no-cache-dir hatch hatch-fancy-pypi-readme hatch-vcs
11+
RUN . /opt/venv/bin/activate && pip install --no-cache-dir --upgrade pip setuptools \
12+
&& cd /src && hatch build -t wheel \
13+
&& pip install --no-cache-dir dist/*-cp*[colorama,d,uvloop]
1214

1315
FROM python:3.11-slim
1416

docs/usage_and_configuration/black_docker_image.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ created for all unreleased
2424
[commits on the `main` branch](https://github.com/psf/black/commits/main). This tag is
2525
not meant to be used by external users.
2626

27+
From version 23.11.0 the Docker image installs a compiled black into the image.
28+
2729
## Usage
2830

2931
A permanent container doesn't have to be created to use _Black_ as a Docker image. It's

0 commit comments

Comments
 (0)