From 60ad0dee25fd00cbbfa93753c26933206566776f Mon Sep 17 00:00:00 2001 From: "Paul Gauthier (aider)" Date: Tue, 9 Jul 2024 18:06:54 +0100 Subject: [PATCH] Implemented a multi-stage Dockerfile to reduce the final image size by removing build dependencies. --- docker/Dockerfile | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index c3299903e..aacecf028 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,14 +1,21 @@ -FROM python:3.10-slim +# Build stage +FROM python:3.10-slim AS builder COPY . /aider -# Unfortunately to build the multi-arch docker image we need `build-essential` for amd64. -# Apparently py-tree-sitter-languages doesn't have a pre-built binary wheel? - RUN apt-get update && \ - apt-get install --no-install-recommends -y build-essential git libportaudio2 && \ + apt-get install --no-install-recommends -y build-essential git && \ rm -rf /var/lib/apt/lists/* && \ pip install --no-cache-dir /aider && \ rm -rf /aider +# Final stage +FROM python:3.10-slim +RUN apt-get update && \ + apt-get install --no-install-recommends -y git libportaudio2 && \ + rm -rf /var/lib/apt/lists/* + +COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages +COPY --from=builder /usr/local/bin/aider /usr/local/bin/aider + WORKDIR /app ENTRYPOINT ["aider"]