diff --git a/CHANGES.md b/CHANGES.md index 9990d8cf459..aa40d87ab71 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -25,8 +25,8 @@ ### Integrations - Allow to pass `target_version` in the vim plugin (#1319) -- Pin regex module to 2021.10.8 in our docker file as it has arm wheels available - (#2579) +- Install build tools in docker file and use multi-stage build to keep the image size + down (#2582) ## 21.9b0 diff --git a/Dockerfile b/Dockerfile index ce88f0ce5e3..c393e29f632 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,17 @@ -FROM python:3-slim +FROM python:3-slim AS builder -# TODO: Remove regex version pin once we get newer arm wheels RUN mkdir /src COPY . /src/ RUN pip install --no-cache-dir --upgrade pip setuptools wheel \ - && apt update && apt install -y git \ + # 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 regex==2021.10.8 \ - && pip install --no-cache-dir .[colorama,d] \ - && rm -rf /src \ - && apt remove -y git \ - && apt autoremove -y \ - && rm -rf /var/lib/apt/lists/* + && pip install --user --no-cache-dir .[colorama,d] + +FROM python:3-slim + +# copy only Python packages to limit the image size +COPY --from=builder /root/.local /root/.local +ENV PATH=/root/.local/bin:$PATH CMD ["black"]