diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index da310f028..7747ac845 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -255,7 +255,7 @@ jobs: - name: Prepare id: prep run: | - TAG=local + TAG=pr PUSH=false if [ "${{ github.event_name }}" = "schedule" ]; then TAG=nightly diff --git a/Makefile b/Makefile index 43127b91c..813fcdf0e 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ binaries: FORCE images: FORCE # moby/buildkit:local and moby/buildkit:local-rootless are created on Docker hack/images local moby/buildkit + TARGET=rootless hack/images local moby/buildkit install: FORCE mkdir -p $(DESTDIR)$(bindir) diff --git a/hack/images b/hack/images index 18933da53..c1231c74c 100755 --- a/hack/images +++ b/hack/images @@ -25,6 +25,23 @@ if [ -z "$TAG" ] || [ -z "$REPO" ]; then usage fi +localmode="" +if [[ "$TAG" == "local" ]]; then + localmode="1" + if [ "$PUSH" = "push" ]; then + echo >&2 "local images cannot be pushed" + exit 1 + fi +fi + +outputFlag="--output=type=image,push=false" +if [ "$PUSH" = "push" ]; then + outputFlag="--output=type=image,push=true" +fi +if [ -n "$localmode" ]; then + outputFlag="--output=type=docker" +fi + pushFlag="push=false" if [ "$PUSH" = "push" ]; then pushFlag="push=true" @@ -35,6 +52,11 @@ if [ -n "$TARGET" ]; then targetFlag="--target=$TARGET" fi +tagMain="$REPO:$TAG" +if [ -n "$TARGET" ]; then + tagMain="$tagMain-$TARGET" +fi + tagLatest="" if [[ "$versionTag" == "$TAG" ]]; then if [ -n "$TARGET" ]; then @@ -44,20 +66,22 @@ if [[ "$versionTag" == "$TAG" ]]; then fi fi -importCacheFlags="--cache-from=type=registry,ref=$REPO:$TAG$tagLatest " +importCacheFlags="--cache-from=type=registry,ref=$tagMain$tagLatest " if [[ -n "$cacheref" ]] && [[ "$cachetype" = "local" ]]; then for ref in $cacheref; do importCacheFlags="$importCacheFlags--cache-from=type=local,src=$ref " done fi +if [ -n "$localmode" ]; then + importCacheFlags="" +fi exportCacheFlags="" if [ "$PUSH" = "push" ]; then exportCacheFlags="--cache-to=type=inline " fi -buildxCmd build $targetFlag $importCacheFlags $exportCacheFlags \ +buildxCmd build $targetFlag $importCacheFlags $exportCacheFlags $outputFlag \ --platform "$PLATFORMS" \ - --tag "$REPO:$TAG$tagLatest" \ - --output "type=image,$pushFlag" \ - $currentref + --tag "$tagMain$tagLatest" \ + $currentcontext