This commit is contained in:
Your Name
2025-05-19 19:16:47 +12:00
parent 6c03512637
commit ee66ab8ec5
2 changed files with 1 additions and 1 deletions

64
publish.sh Executable file
View File

@@ -0,0 +1,64 @@
#!/bin/bash
# Exit on error
set -e
# DIRECTORIES
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
CACHE_DIR="${SCRIPT_DIR}/cache"
EXE_DIR="${SCRIPT_DIR}/exe"
BUILD_DIR="${SCRIPT_DIR}/build"
# FUNCTIONS
function title() {
echo "----------------------------------------"
# Center the text
local text="$1"
local line_length=40
local text_length=${#text}
local padding=$(( (line_length - text_length) / 2 ))
printf "%*s%s%*s\n" $padding "" "$text" $padding ""
echo "----------------------------------------"
}
function die() {
echo " "
title "$1"
echo " "
exit 1
}
#--------------------------------
# MAIN
#--------------------------------
cd $SCRIPT_DIR
if [ ! -f ${EXE_DIR}/simple_object_storage-linux-x86_64 ]; then
die "x86_64 executable not found"
fi
if [ ! -f ${EXE_DIR}/simple_object_storage-linux-arm64 ]; then
die "arm64 executable not found"
fi
# use Docker architecture style
cp ${EXE_DIR}/simple_object_storage-linux-x86_64 ${EXE_DIR}/simple_object_storage-linux-amd64
echo "amd64 executable: ./simple_object_storage-linux-amd64"
echo "arm64 executable: ./simple_object_storage-linux-arm64"
echo "Setting up Docker BuildX builder 'sosbuilder'"
# Check if builder instance exists
if ! docker buildx inspect sosbuilder > /dev/null 2>&1; then
echo "Builder 'sosbuilder' not found, creating..."
docker buildx create --name sosbuilder
else
echo "Builder 'sosbuilder' already exists."
fi
# Ensure the builder is used
docker buildx use sosbuilder
echo "Building multi-platform Docker image"
docker buildx build --push -t gitea.jde.nz/j/simple-object-storage:latest --platform linux/amd64,linux/arm64 .
echo "Build completed successfully!"