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 - name: Prepare
id: prep id: prep
run: | run: |
TAG=local TAG=pr
PUSH=false PUSH=false
if [ "${{ github.event_name }}" = "schedule" ]; then if [ "${{ github.event_name }}" = "schedule" ]; then
TAG=nightly TAG=nightly

View File

@ -7,6 +7,7 @@ binaries: FORCE
images: FORCE images: FORCE
# moby/buildkit:local and moby/buildkit:local-rootless are created on Docker # moby/buildkit:local and moby/buildkit:local-rootless are created on Docker
hack/images local moby/buildkit hack/images local moby/buildkit
TARGET=rootless hack/images local moby/buildkit
install: FORCE install: FORCE
mkdir -p $(DESTDIR)$(bindir) mkdir -p $(DESTDIR)$(bindir)

View File

@ -25,6 +25,23 @@ if [ -z "$TAG" ] || [ -z "$REPO" ]; then
usage usage
fi 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" pushFlag="push=false"
if [ "$PUSH" = "push" ]; then if [ "$PUSH" = "push" ]; then
pushFlag="push=true" pushFlag="push=true"
@ -35,6 +52,11 @@ if [ -n "$TARGET" ]; then
targetFlag="--target=$TARGET" targetFlag="--target=$TARGET"
fi fi
tagMain="$REPO:$TAG"
if [ -n "$TARGET" ]; then
tagMain="$tagMain-$TARGET"
fi
tagLatest="" tagLatest=""
if [[ "$versionTag" == "$TAG" ]]; then if [[ "$versionTag" == "$TAG" ]]; then
if [ -n "$TARGET" ]; then if [ -n "$TARGET" ]; then
@ -44,20 +66,22 @@ if [[ "$versionTag" == "$TAG" ]]; then
fi fi
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 if [[ -n "$cacheref" ]] && [[ "$cachetype" = "local" ]]; then
for ref in $cacheref; do for ref in $cacheref; do
importCacheFlags="$importCacheFlags--cache-from=type=local,src=$ref " importCacheFlags="$importCacheFlags--cache-from=type=local,src=$ref "
done done
fi fi
if [ -n "$localmode" ]; then
importCacheFlags=""
fi
exportCacheFlags="" exportCacheFlags=""
if [ "$PUSH" = "push" ]; then if [ "$PUSH" = "push" ]; then
exportCacheFlags="--cache-to=type=inline " exportCacheFlags="--cache-to=type=inline "
fi fi
buildxCmd build $targetFlag $importCacheFlags $exportCacheFlags \ buildxCmd build $targetFlag $importCacheFlags $exportCacheFlags $outputFlag \
--platform "$PLATFORMS" \ --platform "$PLATFORMS" \
--tag "$REPO:$TAG$tagLatest" \ --tag "$tagMain$tagLatest" \
--output "type=image,$pushFlag" \ $currentcontext
$currentref