Open MrLuje opened 1 year ago
Builder images do not try to be small, but in this case, yes.
Just adding a rm in the script should work.
Just adding a rm in the script should work.
Unfortunately no, it must be copied, extracted and deleted in the same operation for it to not being recorded in the layer.
IMHO a good solution would be to use RUN --mount=type=bind,source=...,target=...
syntax (https://github.com/moby/buildkit/blob/v0.10/frontend/dockerfile/docs/syntax.md#run---mounttypebind-the-default-mount-type) to mount the temp file directly during the RUN
command :
- COPY /target/artifacts/graalvm-jdk-17.0.7-linux-x64.tar.gz /tmp/graalvm/graalvm-jdk-17.0.7-linux-x64.tar.gz
RUN
+ --mount=type=bind,source=/target/artifacts/graalvm-jdk-17.0.7-linux-x64.tar.gz,target=/tmp/graalvm/graalvm-jdk-17.0.7-linux-x64.tar.gz \
tar xzf /tmp/graalvm/graalvm-jdk-17.0.7-linux-x64.tar.gz -C /opt \
&& mv /opt/graalvm-community-openjdk-17.0.7* /opt/graalvm \
- && rm -Rf /tmp/graalvm-jdk-17.0.7-linux-x64.tar.gz
If that's ok with you, I'll open a PR with it
Does that command works with podman
?
I'm not really familiar with Podman but with version 4.5.1, it worked (aliased docker to podman) Will it be caught by CI if there are compatibility issues ?
I was looking at
quay.io/quarkus/ubi-quarkus-graalvmce-builder-image:22.3.2-java17-amd64
with dive and noticed it reported a temporary file costing ~250MB on the final imageThis can be avoided by using a multistage build and extracting the tar in another stage.
From what I see, the biggest gain are on the following images but the same fix could be applied to any image using artifacts :
I'll first open a PR for
ubi-quarkus-graalvmce-builder-image
andubi-quarkus-graalvmce-s2i
since they share the same module