87 lines
2.5 KiB
Bash
Executable File
87 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
APP=$1
|
|
VERSION=$2
|
|
PRERELEASE=$3 # New parameter for pre-release tag
|
|
|
|
if [ -z "$APP" ]; then
|
|
echo "Please provide an app name as an argument."
|
|
echo "Usage: $0 <app_name> <version> [pre-release-tag]"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if version is provided
|
|
if [ -z "$VERSION" ]; then
|
|
echo "Please provide a version number as an argument."
|
|
echo "Usage: $0 $APP <version> [pre-release-tag]"
|
|
exit 1
|
|
fi
|
|
|
|
# Add warning prompt
|
|
if [ -z "$PRERELEASE" ]; then
|
|
read -p "You're building WITHOUT any pre-release ($VERSION). Do you wish to continue (y/N)? " -n 1 -r
|
|
else
|
|
read -p "You're building WITH pre-release ($VERSION). Do you wish to continue (y/N)? " -n 1 -r
|
|
fi
|
|
echo # Move to a new line
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
then
|
|
echo "Aborting..."
|
|
exit 1
|
|
fi
|
|
|
|
# Ensure Docker Buildx is available and set up a builder
|
|
docker buildx rm multi-arch-builder 2>/dev/null || true # Remove existing builder if it exists
|
|
docker buildx create --name multi-arch-builder --use || true
|
|
|
|
# Function to build a multi-architecture image
|
|
build_image() {
|
|
local app=$1
|
|
local image_name="lindesvard/openpanel-$app"
|
|
local full_version="$image_name:$VERSION"
|
|
|
|
# Use apps/start/Dockerfile for dashboard app
|
|
local dockerfile="apps/$app/Dockerfile"
|
|
if [ "$app" = "dashboard" ]; then
|
|
dockerfile="apps/start/Dockerfile"
|
|
fi
|
|
|
|
if [ -n "$PRERELEASE" ]; then
|
|
echo "(pre-release) Building multi-architecture image for $full_version-$PRERELEASE"
|
|
docker buildx build \
|
|
--platform linux/amd64,linux/arm64 \
|
|
-t "$full_version-$PRERELEASE" \
|
|
--build-arg DATABASE_URL="postgresql://p@p:5432/p" \
|
|
-f "$dockerfile" \
|
|
--push \
|
|
.
|
|
else
|
|
echo "(latest) Building multi-architecture image for $full_version"
|
|
docker buildx build \
|
|
--platform linux/amd64,linux/arm64 \
|
|
-t "$full_version" \
|
|
-t "$image_name:latest" \
|
|
--build-arg DATABASE_URL="postgresql://p@p:5432/p" \
|
|
-f "$dockerfile" \
|
|
--push \
|
|
.
|
|
fi
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to build $full_version"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Successfully built and pushed multi-architecture image for $full_version"
|
|
}
|
|
|
|
if [ "$APP" == "all" ]; then
|
|
build_image "dashboard"
|
|
build_image "worker"
|
|
build_image "api"
|
|
echo "All multi-architecture images have been built and pushed successfully."
|
|
else
|
|
build_image $APP
|
|
echo "Multi-architecture image for $APP has been built and pushed successfully."
|
|
fi
|