From 5018bd8d9390f8eb7e994b43ab1ca188cac003cc Mon Sep 17 00:00:00 2001 From: g2flyer Date: Thu, 25 Jan 2024 17:29:20 -0800 Subject: [PATCH 1/2] speed up docker (re-)build by caching pip cache Signed-off-by: g2flyer --- docker/pdo_ccf.dockerfile | 6 +++++- docker/pdo_client.dockerfile | 6 +++++- docker/pdo_services.dockerfile | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docker/pdo_ccf.dockerfile b/docker/pdo_ccf.dockerfile index 6a1ee6b2..20edebbe 100644 --- a/docker/pdo_ccf.dockerfile +++ b/docker/pdo_ccf.dockerfile @@ -14,6 +14,8 @@ # limitations under the License. # ------------------------------------------------------------------------------ +# syntax = docker/dockerfile:experimental + ARG PDO_VERSION FROM pdo_ccf_base:${PDO_VERSION} @@ -44,7 +46,9 @@ WORKDIR /project/pdo/tools COPY --chown=${UNAME}:${UNAME} tools/*.sh ./ # build it!!! -RUN /project/pdo/tools/build_ccf.sh +ARG UID=1000 +ARG GID=${UID} +RUN --mount=type=cache,uid=${UID},gid=${GID},target=/project/pdo/.cache/pip /project/pdo/tools/build_ccf.sh # Network ports for running services EXPOSE 6600 diff --git a/docker/pdo_client.dockerfile b/docker/pdo_client.dockerfile index c8bb7f17..7e024521 100644 --- a/docker/pdo_client.dockerfile +++ b/docker/pdo_client.dockerfile @@ -14,6 +14,8 @@ # limitations under the License. # ------------------------------------------------------------------------------ +# syntax = docker/dockerfile:experimental + ARG PDO_VERSION FROM pdo_base:${PDO_VERSION} @@ -63,7 +65,9 @@ WORKDIR /project/pdo/tools COPY --chown=${UNAME}:${UNAME} tools/*.sh ./ # build it!!! -RUN /project/pdo/tools/build_client.sh +ARG UID=1000 +ARG GID=${UID} +RUN --mount=type=cache,uid=${UID},gid=${GID},target=/project/pdo/.cache/pip /project/pdo/tools/build_client.sh ARG PDO_HOSTNAME ENV PDO_HOSTNAME=$PDO_HOSTNAME diff --git a/docker/pdo_services.dockerfile b/docker/pdo_services.dockerfile index 73710765..dc2a2868 100644 --- a/docker/pdo_services.dockerfile +++ b/docker/pdo_services.dockerfile @@ -14,6 +14,8 @@ # limitations under the License. # ------------------------------------------------------------------------------ +# syntax = docker/dockerfile:experimental + ARG PDO_VERSION FROM pdo_services_base:${PDO_VERSION} @@ -48,7 +50,9 @@ WORKDIR /project/pdo/tools COPY --chown=${UNAME}:${UNAME} tools/*.sh ./ # built it! -RUN /project/pdo/tools/build_services.sh +ARG UID=1000 +ARG GID=${UID} +RUN --mount=type=cache,uid=${UID},gid=${GID},target=/project/pdo/.cache/pip /project/pdo/tools/build_services.sh # Network ports for running services EXPOSE 7001 7002 7003 7004 7005 From 8a178657fa8ce216cde18ef37d00fe5586d4cd44 Mon Sep 17 00:00:00 2001 From: g2flyer Date: Mon, 29 Jan 2024 10:43:14 -0800 Subject: [PATCH 2/2] fixup! speed up docker (re-)build by caching pip cache Signed-off-by: g2flyer --- docker/pdo_ccf.dockerfile | 6 +++++- docker/pdo_client.dockerfile | 6 +++++- docker/pdo_services.dockerfile | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docker/pdo_ccf.dockerfile b/docker/pdo_ccf.dockerfile index 20edebbe..6b182907 100644 --- a/docker/pdo_ccf.dockerfile +++ b/docker/pdo_ccf.dockerfile @@ -15,6 +15,9 @@ # ------------------------------------------------------------------------------ # syntax = docker/dockerfile:experimental +# above enable build-kit extension for 'RUN --mount=type= ..' extension used below +# to cache pip downloads between builds, cutting down noticeably build time. +# Note that cache is cleaned with the "uusal" docker prune commans, e.g., docker builder prune. ARG PDO_VERSION FROM pdo_ccf_base:${PDO_VERSION} @@ -48,7 +51,8 @@ COPY --chown=${UNAME}:${UNAME} tools/*.sh ./ # build it!!! ARG UID=1000 ARG GID=${UID} -RUN --mount=type=cache,uid=${UID},gid=${GID},target=/project/pdo/.cache/pip /project/pdo/tools/build_ccf.sh +RUN --mount=type=cache,uid=${UID},gid=${GID},target=/project/pdo/.cache/pip \ + /project/pdo/tools/build_ccf.sh # Network ports for running services EXPOSE 6600 diff --git a/docker/pdo_client.dockerfile b/docker/pdo_client.dockerfile index 7e024521..0f51a824 100644 --- a/docker/pdo_client.dockerfile +++ b/docker/pdo_client.dockerfile @@ -15,6 +15,9 @@ # ------------------------------------------------------------------------------ # syntax = docker/dockerfile:experimental +# above enable build-kit extension for 'RUN --mount=type= ..' extension used below +# to cache pip downloads between builds, cutting down noticeably build time. +# Note that cache is cleaned with the "uusal" docker prune commans, e.g., docker builder prune. ARG PDO_VERSION FROM pdo_base:${PDO_VERSION} @@ -67,7 +70,8 @@ COPY --chown=${UNAME}:${UNAME} tools/*.sh ./ # build it!!! ARG UID=1000 ARG GID=${UID} -RUN --mount=type=cache,uid=${UID},gid=${GID},target=/project/pdo/.cache/pip /project/pdo/tools/build_client.sh +RUN --mount=type=cache,uid=${UID},gid=${GID},target=/project/pdo/.cache/pip \ + /project/pdo/tools/build_client.sh ARG PDO_HOSTNAME ENV PDO_HOSTNAME=$PDO_HOSTNAME diff --git a/docker/pdo_services.dockerfile b/docker/pdo_services.dockerfile index dc2a2868..2c0fcfd1 100644 --- a/docker/pdo_services.dockerfile +++ b/docker/pdo_services.dockerfile @@ -15,6 +15,9 @@ # ------------------------------------------------------------------------------ # syntax = docker/dockerfile:experimental +# above enable build-kit extension for 'RUN --mount=type= ..' extension used below +# to cache pip downloads between builds, cutting down noticeably build time. +# Note that cache is cleaned with the "uusal" docker prune commans, e.g., docker builder prune. ARG PDO_VERSION FROM pdo_services_base:${PDO_VERSION} @@ -52,7 +55,8 @@ COPY --chown=${UNAME}:${UNAME} tools/*.sh ./ # built it! ARG UID=1000 ARG GID=${UID} -RUN --mount=type=cache,uid=${UID},gid=${GID},target=/project/pdo/.cache/pip /project/pdo/tools/build_services.sh +RUN --mount=type=cache,uid=${UID},gid=${GID},target=/project/pdo/.cache/pip \ + /project/pdo/tools/build_services.sh # Network ports for running services EXPOSE 7001 7002 7003 7004 7005