From 925359aa6b75dd396f1977c376c8f68841f8a0bf Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Mon, 8 Jul 2024 11:28:40 -0700 Subject: [PATCH] chore(ci): mount package directory at image build time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This updates our release workflow to use docker's build-time [bind mount](https://docs.docker.com/reference/dockerfile/#run---mounttypebind) support to supply the package file(s) instead of copying into the image. The idea behind this is that mounting the package removes a large `COPY` layer and reduces the image size. The directory that is mounted is checksum-ed by docker as part of the build context, so build cache is automatically invalidated when the package file changes. ``` $ docker image ls kong/kong-gateway-dev:master \ > --format 'table {{.Repository}}\t{{.Tag}}\t{{.Size}}' REPOSITORY TAG SIZE kong/kong-gateway-dev master 538MB ``` ``` $ docker image history kong/kong-gateway-dev:master \ > --format 'table {{.CreatedAt}}\t{{.CreatedBy}}\t{{.Size}}' CREATED AT CREATED BY SIZE 2024-07-08T01:52:13-07:00 CMD ["kong" "docker-start"] 0B 2024-07-08T01:52:13-07:00 HEALTHCHECK &{["CMD-SHELL" "kong-health"] "1… 0B 2024-07-08T01:52:13-07:00 STOPSIGNAL SIGQUIT 0B 2024-07-08T01:52:13-07:00 EXPOSE map[8000/tcp:{} 8001/tcp:{} 8002/tcp:… 0B 2024-07-08T01:52:13-07:00 ENTRYPOINT ["/entrypoint.sh"] 0B 2024-07-08T01:52:13-07:00 USER kong 0B 2024-07-08T01:52:13-07:00 COPY build/dockerfiles/entrypoint.sh /entryp… 2.22kB 2024-07-08T01:52:13-07:00 RUN |6 KONG_VERSION=3.8.0.0 KONG_PREFIX=/usr… 379MB 2024-07-08T01:51:55-07:00 COPY bazel-bin/pkg/kong.amd64.deb /tmp/kong.… 81.3MB 2024-07-08T01:51:55-07:00 ARG KONG_ARTIFACT_PATH=bazel-bin/pkg/ 0B 2024-07-08T01:51:55-07:00 ARG KONG_ARTIFACT=kong.amd64.deb 0B 2024-07-08T01:51:55-07:00 ARG TARGETARCH=amd64 0B 2024-07-08T01:51:55-07:00 ARG EE_PORTS=8002 8445 8003 8446 8004 8447 0B 2024-07-08T01:51:55-07:00 ENV KONG_PREFIX=/usr/local/kong 0B 2024-07-08T01:51:55-07:00 ARG KONG_PREFIX=/usr/local/kong 0B 2024-07-08T01:51:55-07:00 ENV KONG_VERSION=3.8.0.0 0B 2024-07-08T01:51:55-07:00 ARG KONG_VERSION=3.8.0.0 0B 2024-07-08T01:51:55-07:00 LABEL maintainer=Kong Docker Maintainers --format 'table {{.Repository}}\t{{.Tag}}\t{{.Size}}' REPOSITORY TAG SIZE kong/kong-gateway-dev b5195bbdb9a613a81359b4c1498220738af99a37 457MB ``` ``` $ docker image history kong/kong-gateway-dev:b5195bbdb9a613a81359b4c1498220738af99a37 \ > --format 'table {{.CreatedAt}}\t{{.CreatedBy}}\t{{.Size}}' CREATED AT CREATED BY SIZE 2024-07-08T11:17:32-07:00 CMD ["kong" "docker-start"] 0B 2024-07-08T11:17:32-07:00 HEALTHCHECK &{["CMD-SHELL" "kong-health"] "1… 0B 2024-07-08T11:17:32-07:00 STOPSIGNAL SIGQUIT 0B 2024-07-08T11:17:32-07:00 EXPOSE map[8000/tcp:{} 8001/tcp:{} 8002/tcp:… 0B 2024-07-08T11:17:32-07:00 ENTRYPOINT ["/entrypoint.sh"] 0B 2024-07-08T11:17:32-07:00 USER kong 0B 2024-07-08T11:17:32-07:00 COPY build/dockerfiles/entrypoint.sh /entryp… 2.22kB 2024-07-08T11:17:32-07:00 RUN |6 KONG_VERSION=3.8.0.0 KONG_PREFIX=/usr… 379MB 2024-07-08T11:17:32-07:00 ARG KONG_ARTIFACT_PATH=bazel-bin/pkg 0B 2024-07-08T11:17:32-07:00 ARG KONG_ARTIFACT=kong.amd64.deb 0B 2024-07-08T11:17:32-07:00 ARG TARGETARCH=amd64 0B 2024-07-08T11:17:32-07:00 ARG EE_PORTS=8002 8445 8003 8446 8004 8447 0B 2024-07-08T11:17:32-07:00 ENV KONG_PREFIX=/usr/local/kong 0B 2024-07-08T11:17:32-07:00 ARG KONG_PREFIX=/usr/local/kong 0B 2024-07-08T11:17:32-07:00 ENV KONG_VERSION=3.8.0.0 0B 2024-07-08T11:17:32-07:00 ARG KONG_VERSION=3.8.0.0 0B 2024-07-08T11:17:32-07:00 LABEL maintainer=Kong Docker Maintainers