Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable cross-platform docker image generation via docker buildx #11

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions build-docker-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,19 @@ if [[ "$BRANCH" == "master" ]]; then
done
fi

# default build targets can be configured with the DOCKER_BUILD_PLATFORMS env var
DOCKER_BUILD_DEFAULT_PLATFORMS='linux/amd64,linux/arm64,linux/arm/v7'
DOCKER_BUILD_PLATFORMS=${DOCKER_BUILD_PLATFORMS:-$DOCKER_BUILD_DEFAULT_PLATFORMS}

# log in to Docker Hub _before_ building to avoid rate limits
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"

# Build and push each tag (the built image will be reused after the first build)
for tag in ${tags[@]}; do
docker build -t $tag .
docker push $tag
if [ $DOCKER_BUILD_PLATFORMS == "classic" ]; then
docker build -t $tag .
docker push $tag
else
docker buildx build --push --platform="$DOCKER_BUILD_PLATFORMS" -t $tag .
fi
done