Skip to content

Commit 0853cc0

Browse files
committed
added docker hub hook for multi-platform build
1 parent c71d61d commit 0853cc0

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

docker/hooks/build

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
echo "display path"
4+
echo "$(pwd)"
5+
echo "display dockerfile path"
6+
echo $DOCKERFILE_PATH
7+
cd ..
8+
echo "display path"
9+
echo "$(pwd)"
10+
echo "current branch"
11+
echo "$SOURCE_BRANCH"
12+
13+
version_regex='^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'
14+
if [[ "$SOURCE_BRANCH" == "master" || "$SOURCE_BRANCH" =~ $version_regex ]]; then
15+
echo "The branch is master, proceeding with multi-arch build"
16+
docker buildx create --name multiarch --use
17+
docker buildx build -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" --platform linux/arm64,linux/amd64 --push .
18+
else
19+
echo "The branch is not master, proceeding with classic build"
20+
docker buildx build -f "$DOCKERFILE_PATH" -t "$IMAGE_NAME" --push .
21+
fi

docker/hooks/post_push

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
if [[ "$SOURCE_BRANCH" == "master" ]]; then
4+
curl -d "text=A new production image has been pushed to Docker Hub" -d "channel=$SLACK_CHANNEL" -H "Authorization: Bearer $SLACK_TOKEN" -X POST https://slack.com/api/chat.postMessage
5+
fi

0 commit comments

Comments
 (0)