mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 19:38:13 +00:00
[improvement][docker]Support multi-platform builds.
This commit is contained in:
6
.github/workflows/docker-publish.yml
vendored
6
.github/workflows/docker-publish.yml
vendored
@@ -28,7 +28,5 @@ jobs:
|
|||||||
- name: Build and publish Docker image
|
- name: Build and publish Docker image
|
||||||
run: |
|
run: |
|
||||||
VERSION=${{ github.event.inputs.version }}
|
VERSION=${{ github.event.inputs.version }}
|
||||||
chmod +x docker/docker-build.sh
|
chmod +x docker/docker-build-publish.sh
|
||||||
chmod +x docker/docker-publish.sh
|
sh docker/docker-build-publish.sh $VERSION
|
||||||
sh docker/docker-build.sh $VERSION
|
|
||||||
sh docker/docker-publish.sh $VERSION
|
|
||||||
|
|||||||
34
docker/docker-build-publish.sh
Normal file
34
docker/docker-build-publish.sh
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Function to execute the build script
|
||||||
|
execute_build_script() {
|
||||||
|
echo "Executing build script: assembly/bin/supersonic-build.sh"
|
||||||
|
assembly/bin/supersonic-build.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to build the Docker image
|
||||||
|
build_docker_image() {
|
||||||
|
local version=$1
|
||||||
|
echo "Building Docker image: supersonic:$version"
|
||||||
|
docker buildx build --no-cache --platform linux/amd64,linux/arm64 \
|
||||||
|
--build-arg SUPERSONIC_VERSION=$version \
|
||||||
|
-t supersonicbi/supersonic:$version \
|
||||||
|
-t supersonicbi/supersonic:latest \
|
||||||
|
-f docker/Dockerfile \
|
||||||
|
--push .
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Docker build failed. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Docker image supersonic:$version built successfully."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main script execution
|
||||||
|
VERSION=$1
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
echo "Usage: $0 <version>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
execute_build_script
|
||||||
|
build_docker_image $VERSION
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# Exit immediately if a command exits with a non-zero status
|
|
||||||
set -e
|
|
||||||
VERSION=$1
|
|
||||||
|
|
||||||
# Image name
|
|
||||||
IMAGE_NAME="supersonicbi/supersonic"
|
|
||||||
|
|
||||||
# Default tag is latest
|
|
||||||
TAGS="latest"
|
|
||||||
|
|
||||||
# If VERSION is provided, add it to TAGS and tag the image as latest
|
|
||||||
if [ -n "$VERSION" ]; then
|
|
||||||
TAGS="$TAGS $VERSION"
|
|
||||||
echo "Tagging Docker images $IMAGE_NAME:$VERSION to $IMAGE_NAME:latest"
|
|
||||||
docker tag $IMAGE_NAME:$VERSION $IMAGE_NAME:latest
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Push Docker images
|
|
||||||
for TAG in $TAGS; do
|
|
||||||
echo "Pushing Docker image $IMAGE_NAME:$TAG"
|
|
||||||
docker push $IMAGE_NAME:$TAG
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Docker images pushed successfully."
|
|
||||||
Reference in New Issue
Block a user