From 693ca45665362f6af502d592ce9d5127d19a2a54 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Fri, 26 Jun 2020 06:05:08 +0200 Subject: [PATCH 1/3] We probably want to "export all the layers of all intermediate steps" --- bin/y-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/y-build b/bin/y-build index 4501c8d9..7da8f940 100755 --- a/bin/y-build +++ b/bin/y-build @@ -14,7 +14,7 @@ DEFAULT_REGISTRY=builds-registry.ystack.svc.cluster.local [ -z "$PUSH_REGISTRY" ] && PUSH_REGISTRY=$DEFAULT_REGISTRY [ -z "$BUILDKIT_CACHE" ] && BUILDKIT_CACHE="type=registry,ref=$BUILDS_REGISTRY/ystack:buildcache" [ -z "$IMPORT_CACHE" ] && IMPORT_CACHE="--import-cache=$BUILDKIT_CACHE" -[ -z "$EXPORT_CACHE" ] && EXPORT_CACHE="--export-cache=$BUILDKIT_CACHE" +[ -z "$EXPORT_CACHE" ] && EXPORT_CACHE="--export-cache=$BUILDKIT_CACHE,mode=max" [ "$IMPORT_CACHE" = "false" ] && IMPORT_CACHE="" [ "$EXPORT_CACHE" = "false" ] && EXPORT_CACHE="" [ -z "$BUILDKIT_HOST" ] && BUILDKIT_HOST=tcp://buildkitd.ystack.svc.cluster.local:8547 From f5f13c811ba9675cd64eff441c146d3c4badbaf9 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Fri, 26 Jun 2020 06:10:28 +0200 Subject: [PATCH 2/3] Try caching per output image name --- bin/y-build | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bin/y-build b/bin/y-build index 7da8f940..12816205 100755 --- a/bin/y-build +++ b/bin/y-build @@ -12,11 +12,6 @@ BUILDCTL_OPTS="$@" DEFAULT_REGISTRY=builds-registry.ystack.svc.cluster.local [ -z "$BUILDS_REGISTRY" ] && BUILDS_REGISTRY=$DEFAULT_REGISTRY [ -z "$PUSH_REGISTRY" ] && PUSH_REGISTRY=$DEFAULT_REGISTRY -[ -z "$BUILDKIT_CACHE" ] && BUILDKIT_CACHE="type=registry,ref=$BUILDS_REGISTRY/ystack:buildcache" -[ -z "$IMPORT_CACHE" ] && IMPORT_CACHE="--import-cache=$BUILDKIT_CACHE" -[ -z "$EXPORT_CACHE" ] && EXPORT_CACHE="--export-cache=$BUILDKIT_CACHE,mode=max" -[ "$IMPORT_CACHE" = "false" ] && IMPORT_CACHE="" -[ "$EXPORT_CACHE" = "false" ] && EXPORT_CACHE="" [ -z "$BUILDKIT_HOST" ] && BUILDKIT_HOST=tcp://buildkitd.ystack.svc.cluster.local:8547 if [ "$(curl -s --connect-timeout 3 http://$BUILDS_REGISTRY/v2/)" != "{}" ] @@ -65,6 +60,12 @@ if [[ ! -z "$GIT_COMMIT" ]]; then fi fi +[ -z "$BUILDKIT_CACHE" ] && BUILDKIT_CACHE="type=registry,ref=$(echo $IMAGE | sed 's|/|/ystack-buildcache/|' | sed s/:$BUILD_TAG//)" +[ -z "$IMPORT_CACHE" ] && IMPORT_CACHE="--import-cache=$BUILDKIT_CACHE" +[ -z "$EXPORT_CACHE" ] && EXPORT_CACHE="--export-cache=$BUILDKIT_CACHE,mode=max" +[ "$IMPORT_CACHE" = "false" ] && IMPORT_CACHE="" +[ "$EXPORT_CACHE" = "false" ] && EXPORT_CACHE="" + echo "Build command:" set -x y-buildctl \ From 0db691fa8ec7683f4b61109ce2e039a550c90fc6 Mon Sep 17 00:00:00 2001 From: Staffan Olsson Date: Fri, 26 Jun 2020 06:18:37 +0200 Subject: [PATCH 3/3] Make sure we cache to the builds registry --- bin/y-build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/y-build b/bin/y-build index 12816205..7ec72372 100755 --- a/bin/y-build +++ b/bin/y-build @@ -60,7 +60,8 @@ if [[ ! -z "$GIT_COMMIT" ]]; then fi fi -[ -z "$BUILDKIT_CACHE" ] && BUILDKIT_CACHE="type=registry,ref=$(echo $IMAGE | sed 's|/|/ystack-buildcache/|' | sed s/:$BUILD_TAG//)" +REGISTRY_CACHE_DEFAULT=$(echo $IMAGE | sed "s|[^/]*|$BUILDS_REGISTRY/ystack-buildcache|" | sed "s/:$BUILD_TAG//") +[ -z "$BUILDKIT_CACHE" ] && BUILDKIT_CACHE="type=registry,ref=$REGISTRY_CACHE_DEFAULT" [ -z "$IMPORT_CACHE" ] && IMPORT_CACHE="--import-cache=$BUILDKIT_CACHE" [ -z "$EXPORT_CACHE" ] && EXPORT_CACHE="--export-cache=$BUILDKIT_CACHE,mode=max" [ "$IMPORT_CACHE" = "false" ] && IMPORT_CACHE=""