diff --git a/bin/y-build b/bin/y-build index 4501c8d9..7ec72372 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" -[ "$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,13 @@ if [[ ! -z "$GIT_COMMIT" ]]; then fi fi +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="" +[ "$EXPORT_CACHE" = "false" ] && EXPORT_CACHE="" + echo "Build command:" set -x y-buildctl \