Skip to content

Commit

Permalink
Reset CLI config after annotating (#65)
Browse files Browse the repository at this point in the history
Permission to push was denied
  • Loading branch information
bilde2910 committed Dec 7, 2019
1 parent 925b7b8 commit 37d7e47
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
21 changes: 21 additions & 0 deletions hooks/post_push
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
#!/bin/sh

# Enable Docker CLI experimental mode
CREATED=false
CONFPATH=~/.docker/config.json
if ! [ -f "$CONFPATH" ]; then
CREATED=true
if ! [ -d ~/.docker ]; then
mkdir -pv ~/.docker
fi
jq -n '.experimental="enabled"' > "$CONFPATH"
else
TMPFILE=`mktemp`
jq '.experimental="enabled"' "$CONFPATH" > "$TMPFILE"
rm "$CONFPATH"
mv "$TMPFILE" "$CONFPATH"
fi

# Create manifest and annotate multiarch image
docker manifest create $IMAGE_NAME $IMAGE_NAME-amd64 $IMAGE_NAME-arm32v7 $IMAGE_NAME-arm64v8
docker manifest annotate $IMAGE_NAME $IMAGE_NAME-amd64 --os linux --arch amd64
docker manifest annotate $IMAGE_NAME $IMAGE_NAME-arm32v7 --os linux --arch arm --variant v7
docker manifest annotate $IMAGE_NAME $IMAGE_NAME-arm64v8 --os linux --arch arm64

# If the config was created, delete it after we're done
if [ "$CREATED" = "true" ]; then
rm "$CONFPATH"
fi

# Replace image in registry
docker manifest push --purge $IMAGE_NAME
14 changes: 0 additions & 14 deletions hooks/pre_build
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,5 @@ apt -y --only-upgrade install docker-ee
apt -y install qemu-user-static jq
cp /usr/bin/qemu-*-static .

# Enable Docker CLI experimental mode
CONFPATH=~/.docker/config.json
if ! [ -f "$CONFPATH" ]; then
if ! [ -d ~/.docker ]; then
mkdir -pv ~/.docker
fi
jq -n '.experimental="enabled"' > "$CONFPATH"
else
TMPFILE=`mktemp`
jq '.experimental="enabled"' "$CONFPATH" > "$TMPFILE"
rm "$CONFPATH"
mv "$TMPFILE" "$CONFPATH"
fi

# Register QEMU
docker run --rm --privileged multiarch/qemu-user-static:register --reset

0 comments on commit 37d7e47

Please sign in to comment.