Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Docker image to hatch + compile #3965

Merged
merged 4 commits into from Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Expand Up @@ -22,6 +22,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