Skip to content

Commit

Permalink
Move Docker image to hatch + compile (#3965)
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperlees committed Oct 23, 2023
1 parent 7f1c578 commit d291c23
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Expand Up @@ -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 -->
Expand Down
12 changes: 7 additions & 5 deletions Dockerfile
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions docs/usage_and_configuration/black_docker_image.md
Expand Up @@ -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
Expand Down

0 comments on commit d291c23

Please sign in to comment.