From b5af93d0d93fe92dec54f2983442d9c2f1b33d7d Mon Sep 17 00:00:00 2001 From: Fred Dubois <169247+duboisf@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:53:45 -0500 Subject: [PATCH] Decrease docker image size by 200MB Copying and then deleting the docker directory in 2 steps (therefore, layers) means the docker directory is still present in the previous layer. We uncompress the docker.tgz in the /tmp directory to be able to copy the docker binaries directly to their target destination. --- images/Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/images/Dockerfile b/images/Dockerfile index 50b4a6b2d27..52335efe1d7 100644 --- a/images/Dockerfile +++ b/images/Dockerfile @@ -25,7 +25,7 @@ RUN export RUNNER_ARCH=${TARGETARCH} \ && if [ "$RUNNER_ARCH" = "amd64" ]; then export DOCKER_ARCH=x86_64 ; fi \ && if [ "$RUNNER_ARCH" = "arm64" ]; then export DOCKER_ARCH=aarch64 ; fi \ && curl -fLo docker.tgz https://download.docker.com/${TARGETOS}/static/stable/${DOCKER_ARCH}/docker-${DOCKER_VERSION}.tgz \ - && tar zxvf docker.tgz \ + && tar -C /tmp -zxvf docker.tgz \ && rm -rf docker.tgz \ && mkdir -p /usr/local/lib/docker/cli-plugins \ && curl -fLo /usr/local/lib/docker/cli-plugins/docker-buildx \ @@ -61,7 +61,6 @@ WORKDIR /home/runner COPY --chown=runner:docker --from=build /actions-runner . COPY --from=build /usr/local/lib/docker/cli-plugins/docker-buildx /usr/local/lib/docker/cli-plugins/docker-buildx - -RUN install -o root -g root -m 755 docker/* /usr/bin/ && rm -rf docker +COPY --chown=root:root --chmod=755 --from=build /tmp/docker/* /usr/bin/ USER runner