From 67f1b25424b05541dd9c9a5077f3fede933405aa Mon Sep 17 00:00:00 2001 From: sanderegg <35365065+sanderegg@users.noreply.github.com> Date: Fri, 26 May 2023 14:24:17 +0200 Subject: [PATCH] do not remove cache if we save it between dockerfiles --- packages/postgres-database/docker/Dockerfile | 6 ++---- packages/service-integration/Dockerfile | 4 +--- services/agent/Dockerfile | 8 ++------ services/api-server/Dockerfile | 8 ++------ services/autoscaling/Dockerfile | 4 +--- services/catalog/Dockerfile | 8 ++------ services/dask-sidecar/Dockerfile | 4 +--- services/datcore-adapter/Dockerfile | 8 ++------ services/director-v2/Dockerfile | 8 ++------ services/director/Dockerfile | 8 ++------ services/dynamic-sidecar/Dockerfile | 8 +++----- services/invitations/Dockerfile | 8 ++------ services/migration/Dockerfile | 4 +--- services/osparc-gateway-server/Dockerfile | 6 +----- services/resource-usage-tracker/Dockerfile | 8 ++------ services/storage/Dockerfile | 8 ++------ services/web/Dockerfile | 12 ++++-------- 17 files changed, 32 insertions(+), 88 deletions(-) diff --git a/packages/postgres-database/docker/Dockerfile b/packages/postgres-database/docker/Dockerfile index d06eef136e9b..81064779f895 100644 --- a/packages/postgres-database/docker/Dockerfile +++ b/packages/postgres-database/docker/Dockerfile @@ -16,10 +16,8 @@ FROM base as build RUN apt-get update \ && apt-get install -y --no-install-recommends \ - build-essential \ - git \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + build-essential \ + git # NOTE: python virtualenv is used here such that installed packages may be moved to production image easily by copying the venv diff --git a/packages/service-integration/Dockerfile b/packages/service-integration/Dockerfile index a4d55e5ac0c4..b307cba7481d 100644 --- a/packages/service-integration/Dockerfile +++ b/packages/service-integration/Dockerfile @@ -42,9 +42,7 @@ FROM base as build RUN apt-get update \ && apt-get install -y --no-install-recommends \ - build-essential \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + build-essential # NOTE: python virtualenv is used here such that installed diff --git a/services/agent/Dockerfile b/services/agent/Dockerfile index 283a385c888b..9e36e8bced17 100644 --- a/services/agent/Dockerfile +++ b/services/agent/Dockerfile @@ -19,9 +19,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock apt-get install -y --no-install-recommends \ gosu \ curl \ - && apt-get autoclean -y \ - && apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* \ + && apt-get clean -y \ # verify that the binary works && gosu nobody true @@ -69,9 +67,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock set -eux \ && apt-get update \ && apt-get install -y --no-install-recommends \ - build-essential \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + build-essential # NOTE: python virtualenv is used here such that installed diff --git a/services/api-server/Dockerfile b/services/api-server/Dockerfile index c7dd4feb40dc..0591a60d047a 100644 --- a/services/api-server/Dockerfile +++ b/services/api-server/Dockerfile @@ -17,9 +17,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock apt-get update && \ apt-get install -y --no-install-recommends \ gosu \ - && apt-get autoclean -y \ - && apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* \ + && apt-get clean -y \ # verify that the binary works && gosu nobody true @@ -66,9 +64,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock set -eux \ && apt-get update \ && apt-get install -y --no-install-recommends \ - build-essential \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + build-essential # NOTE: python virtualenv is used here such that installed diff --git a/services/autoscaling/Dockerfile b/services/autoscaling/Dockerfile index cb55fa276031..fedf5dca601f 100644 --- a/services/autoscaling/Dockerfile +++ b/services/autoscaling/Dockerfile @@ -84,9 +84,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock set -eux \ && apt-get update \ && apt-get install -y --no-install-recommends \ - build-essential \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + build-essential # NOTE: python virtualenv is used here such that installed diff --git a/services/catalog/Dockerfile b/services/catalog/Dockerfile index dc4c75871a43..dc2f399a1d65 100644 --- a/services/catalog/Dockerfile +++ b/services/catalog/Dockerfile @@ -18,9 +18,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock apt-get update && \ apt-get install -y --no-install-recommends \ gosu \ - && apt-get autoclean -y \ - && apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* \ + && apt-get clean -y \ # verify that the binary works && gosu nobody true @@ -67,9 +65,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock set -eux \ && apt-get update \ && apt-get install -y --no-install-recommends \ - build-essential \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + build-essential # NOTE: python virtualenv is used here such that installed # packages may be moved to production image easily by copying the venv diff --git a/services/dask-sidecar/Dockerfile b/services/dask-sidecar/Dockerfile index c5b4a966b380..1fb11fc05c26 100644 --- a/services/dask-sidecar/Dockerfile +++ b/services/dask-sidecar/Dockerfile @@ -73,9 +73,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=loc set -eux \ && apt-get update \ && apt-get install -y --no-install-recommends \ - build-essential \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + build-essential # NOTE: python virtualenv is used here such that installed packages may be moved to production image easily by copying the venv diff --git a/services/datcore-adapter/Dockerfile b/services/datcore-adapter/Dockerfile index 0061131c6717..3372e650227a 100644 --- a/services/datcore-adapter/Dockerfile +++ b/services/datcore-adapter/Dockerfile @@ -18,9 +18,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock apt-get update && \ apt-get install -y --no-install-recommends \ gosu \ - && apt-get autoclean -y \ - && apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* \ + && apt-get clean -y \ # verify that the binary works && gosu nobody true @@ -67,9 +65,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock set -eux \ && apt-get update \ && apt-get install -y --no-install-recommends \ - build-essential \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + build-essential # NOTE: python virtualenv is used here such that installed diff --git a/services/director-v2/Dockerfile b/services/director-v2/Dockerfile index 0be3f679f2be..9789ab5a962c 100644 --- a/services/director-v2/Dockerfile +++ b/services/director-v2/Dockerfile @@ -18,9 +18,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock apt-get update && \ apt-get install -y --no-install-recommends \ gosu \ - && apt-get autoclean -y \ - && apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* \ + && apt-get clean -y \ # verify that the binary works && gosu nobody true @@ -67,9 +65,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock set -eux \ && apt-get update \ && apt-get install -y --no-install-recommends \ - build-essential \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + build-essential # NOTE: python virtualenv is used here such that installed diff --git a/services/director/Dockerfile b/services/director/Dockerfile index 9ede656f0499..c08c399e874c 100644 --- a/services/director/Dockerfile +++ b/services/director/Dockerfile @@ -17,9 +17,7 @@ RUN --mount=type=cache,id=basecache36,target=/var/cache/apt,mode=0755,sharing=lo apt-get update && \ apt-get install -y --no-install-recommends \ gosu \ - && apt-get autoclean -y \ - && apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* \ + && apt-get clean -y \ # verify that the binary works && gosu nobody true @@ -76,9 +74,7 @@ RUN --mount=type=cache,id=basecache36,target=/var/cache/apt,mode=0755,sharing=lo && apt-get update \ && apt-get install -y --no-install-recommends \ build-essential \ - git \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + git # NOTE: python virtualenv is used here such that installed packages may be moved to production image easily by copying the venv diff --git a/services/dynamic-sidecar/Dockerfile b/services/dynamic-sidecar/Dockerfile index ccb76c44daec..07ae1cd4efe7 100644 --- a/services/dynamic-sidecar/Dockerfile +++ b/services/dynamic-sidecar/Dockerfile @@ -78,9 +78,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock set -eux \ && apt-get update \ && apt-get install -y --no-install-recommends \ - build-essential \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + build-essential # NOTE: python virtualenv is used here such that installed # packages may be moved to production image easily by copying the venv @@ -121,8 +119,8 @@ WORKDIR /build/services/dynamic-sidecar RUN --mount=type=cache,mode=0777,target=/root/.cache/pip \ pip --no-cache-dir install \ - --requirement requirements/prod.txt &&\ - pip --no-cache-dir list -v + --requirement requirements/prod.txt \ + && pip --no-cache-dir list -v # --------------------------Production stage ------------------- # Final cleanup up to reduce image size and startup setup diff --git a/services/invitations/Dockerfile b/services/invitations/Dockerfile index 1e1df7d794cf..18ea59c5927e 100644 --- a/services/invitations/Dockerfile +++ b/services/invitations/Dockerfile @@ -18,9 +18,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock apt-get update && \ apt-get install -y --no-install-recommends \ gosu \ - && apt-get autoclean -y \ - && apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* \ + && apt-get clean -y \ # verify that the binary works && gosu nobody true @@ -66,9 +64,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock set -eux \ && apt-get update \ && apt-get install -y --no-install-recommends \ - build-essential \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + build-essential # NOTE: python virtualenv is used here such that installed diff --git a/services/migration/Dockerfile b/services/migration/Dockerfile index fa2257653197..f988629c8fa9 100644 --- a/services/migration/Dockerfile +++ b/services/migration/Dockerfile @@ -38,9 +38,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock && apt-get update \ && apt-get install -y --no-install-recommends \ build-essential \ - git \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + git # NOTE: python virtualenv is used here such that installed packages may be moved to production image easily by copying the venv diff --git a/services/osparc-gateway-server/Dockerfile b/services/osparc-gateway-server/Dockerfile index 59de17741ea4..4b600b9ff4d5 100644 --- a/services/osparc-gateway-server/Dockerfile +++ b/services/osparc-gateway-server/Dockerfile @@ -16,8 +16,6 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=loc gosu \ libffi-dev \ libffi7 \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* \ # verify that the binary works && gosu nobody true @@ -67,9 +65,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=loc && apt-get install -y --no-install-recommends \ build-essential \ git \ - golang-go \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + golang-go # NOTE: python virtualenv is used here such that installed packages may be moved to production image easily by copying the venv diff --git a/services/resource-usage-tracker/Dockerfile b/services/resource-usage-tracker/Dockerfile index b0259cc16a29..c30d523c5796 100644 --- a/services/resource-usage-tracker/Dockerfile +++ b/services/resource-usage-tracker/Dockerfile @@ -18,9 +18,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock apt-get update && \ apt-get install -y --no-install-recommends \ gosu \ - && apt-get autoclean -y \ - && apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* \ + && apt-get clean -y \ # verify that the binary works && gosu nobody true @@ -67,9 +65,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock set -eux \ && apt-get update \ && apt-get install -y --no-install-recommends \ - build-essential \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + build-essential # NOTE: python virtualenv is used here such that installed diff --git a/services/storage/Dockerfile b/services/storage/Dockerfile index ff3bf42a0cf8..05fa16857384 100644 --- a/services/storage/Dockerfile +++ b/services/storage/Dockerfile @@ -17,9 +17,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock apt-get update && \ apt-get install -y --no-install-recommends \ gosu \ - && apt-get autoclean -y \ - && apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* \ + && apt-get clean -y \ # verify that the binary works && gosu nobody true @@ -75,9 +73,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock && apt-get update \ && apt-get install -y --no-install-recommends \ build-essential \ - git \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + git # NOTE: python virtualenv is used here such that installed diff --git a/services/web/Dockerfile b/services/web/Dockerfile index 1fb166148e13..acb480839977 100644 --- a/services/web/Dockerfile +++ b/services/web/Dockerfile @@ -19,9 +19,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock apt-get update && \ apt-get install -y --no-install-recommends \ gosu \ - && apt-get autoclean -y \ - && apt-get autoremove -y \ - && rm -rf /var/lib/apt/lists/* \ + && apt-get clean -y \ # verify that the binary works && gosu nobody true @@ -77,9 +75,7 @@ RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=lock && apt-get update \ && apt-get install -y --no-install-recommends \ build-essential \ - libmagic1 \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + libmagic1 # NOTE: python virtualenv is used here such that installed @@ -117,8 +113,8 @@ COPY --chown=scu:scu services/web/server /build/services/web/server WORKDIR /build/services/web/server # libmagic is requried by the exporter -RUN --mount=type=cache,id=basecache,target=/var/cache/apt,mode=0755,sharing=locked \ - --mount=type=cache,id=baseapt,target=/var/lib/apt,mode=0755,sharing=locked \ +RUN --mount=type=cache,id=webprodcache,target=/var/cache/apt,mode=0755,sharing=locked \ + --mount=type=cache,id=webprodapt,target=/var/lib/apt,mode=0755,sharing=locked \ set -eux \ && apt-get update \ && apt-get install -y --no-install-recommends \