Skip to content

Commit 037e1cf

Browse files
docker: bind-mount the wheels instead of COPY + rm
COPY --from=builder /wheels /wheels commits the wheels as their own layer; the rm -r /wheels in the next RUN writes a whiteout and does not un-commit them, so they ship in every pull. Measured on the published image pythonopenapi/openapi-spec-validator:0.8.2: layer ef2bee5a338d is 1,698,738 of 25,227,374 compressed bytes on amd64 (6.73%), and 1,674,155 of 25,602,635 on arm64. Bind-mounting the builder stage's /wheels for the one RUN that needs it installs the same wheels without committing them, and makes the rm unnecessary. Requires BuildKit, which docker-publish.yml already uses.
1 parent 2121137 commit 037e1cf

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎Dockerfile‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ FROM python:3.14.5-alpine
1313

1414
ARG OPENAPI_SPEC_VALIDATOR_VERSION
1515

16-
COPY --from=builder /wheels /wheels
1716
RUN apk add --no-cache libgcc
18-
RUN pip install --no-cache-dir --pre --find-links /wheels openapi-spec-validator==${OPENAPI_SPEC_VALIDATOR_VERSION} && \
19-
rm -r /wheels
17+
RUN --mount=type=bind,from=builder,source=/wheels,target=/wheels \
18+
pip install --no-cache-dir --pre --find-links /wheels openapi-spec-validator==${OPENAPI_SPEC_VALIDATOR_VERSION}
2019

2120
ENTRYPOINT ["openapi-spec-validator"]

0 commit comments

Comments
 (0)