Merge pull request #1848 from crazy-max/fix-rootless-tag

Fix rootless tag
v0.8
Tõnis Tiigi 2020-11-25 23:41:42 -08:00 committed by GitHub
commit 990fd95310
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 6 deletions

View File

@ -255,7 +255,7 @@ jobs:
- name: Prepare
id: prep
run: |
TAG=local
TAG=pr
PUSH=false
if [ "${{ github.event_name }}" = "schedule" ]; then
TAG=nightly

View File

@ -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)

View File

@ -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