From 0b0494baed6d6a3e8c86a205ebfbe06e31896dba Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Wed, 14 Aug 2024 17:50:07 +0100 Subject: [PATCH] Split out the docker build and final image Try and work around an issue aith gcc in the python armv7 images https://github.com/docker-library/python/issues/869#issuecomment-1744826183 --- Dockerfile | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 15d6c2b..1640791 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,19 @@ -FROM --platform=$TARGETPLATFORM python:3.11-slim +# Split out the wheel build into the non-slim image +# See https://github.com/docker-library/python/issues/869 +FROM python:3.12 AS build +COPY requirements.txt ./ +RUN --mount=type=cache,target=/var/cache/buildkit/pip \ + pip wheel --wheel-dir /wheels -r requirements.txt + +FROM python:3.12-slim LABEL org.opencontainers.image.source=https://github.com/mdiluz/matchy LABEL org.opencontainers.image.description="Matchy matches matchees" LABEL org.opencontainers.image.licenses=Unlicense -WORKDIR /usr/src/app COPY requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt +COPY --from=build /wheels /wheels +RUN --mount=type=cache,target=/var/cache/buildkit/pip \ + pip install --find-links /wheels --no-index -r requirements.txt + COPY . . CMD ["python", "py/matchy.py"] \ No newline at end of file