Skip to content

Commit

Permalink
Merge pull request #1 from BlueWhaleKo/master
Browse files Browse the repository at this point in the history
feature: support linux/arm64 architecture
  • Loading branch information
christallire authored May 11, 2022
2 parents 28e8b35 + 929b323 commit 5460016
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build-and-push:
./scripts/build-and-push.sh ghcr.io/rtcamp/action-slack-notify:v2.2.0
60 changes: 60 additions & 0 deletions scripts/build-and-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

IMAGE=$1
BUILDX_INSTANCE="action-slack-notify-builder"
PLATFORMS="linux/arm64,linux/amd64"

function print_usage {
echo "$0 <Image>"
}

function validate_command_line_args {
if [[ -z "$IMAGE" ]]; then
echo "Image is not supplied"
print_usage
exit 1
fi

echo "=================================="
echo "Arguments"
echo "Image: $IMAGE"
echo "=================================="
}

function validate_docker_installed {
if ! [[ $(command -v docker) ]]; then
echo "Docker is not installed. Install docker first"
exit 1
fi
}

function setup_buildx_platforms {
echo "Install buildx platforms"
docker run --privileged --rm tonistiigi/binfmt --install all > /dev/null
}

function setup_buildx_instance {
echo "Check buildx instance '$BUILDX_INSTANCE' is set"

if [[ $(docker buildx ls | grep $BUILDX_INSTANCE | grep docker-container | wc -l ) -eq 0 ]]; then
echo "Create buildx instance '$BUILDX_INSTANCE'"
docker buildx create --name=$BUILDX_INSTANCE --driver=docker-container
echo "Successfully created and converted to buildx instance '$BUILDX_INSTANCE'"
else
echo "Buildx instance $BUILDX_INSTANCE is ready. Skip..."
fi
}

function build_and_push_images {
echo "Build and push docker images"
docker buildx build --builder=$BUILDX_INSTANCE --platform=$PLATFORMS --push -t $IMAGE .
}


validate_command_line_args
validate_docker_installed

setup_buildx_platforms
setup_buildx_instance

build_and_push_images

0 comments on commit 5460016

Please sign in to comment.