32 lines
890 B
Bash
Executable File
32 lines
890 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
# Default to "latest" if no tag is provided
|
|
TAG=${1:-latest}
|
|
IMAGE_NAME="gitea.oncloud.my.id/wartana/speedtest-ookla"
|
|
FULL_IMAGE_NAME="${IMAGE_NAME}:${TAG}"
|
|
|
|
echo "Building and pushing multi-architecture image: $FULL_IMAGE_NAME"
|
|
|
|
# Ensure buildx is set up and create a new builder instance if one doesn't exist
|
|
if ! docker buildx ls | grep -q 'speedtest-builder'; then
|
|
echo "Creating new buildx builder instance..."
|
|
docker buildx create --name speedtest-builder --use
|
|
else
|
|
echo "Using existing buildx builder instance..."
|
|
docker buildx use speedtest-builder
|
|
fi
|
|
|
|
# Boot up the builder
|
|
docker buildx inspect --bootstrap
|
|
|
|
# Build and push the image for amd64, arm64, and arm/v7 (arm32)
|
|
docker buildx build \
|
|
--platform linux/amd64,linux/arm64,linux/arm/v7 \
|
|
-t "$FULL_IMAGE_NAME" \
|
|
--push \
|
|
.
|
|
|
|
echo "Successfully built and pushed $FULL_IMAGE_NAME"
|