1
0

fix: 更新Docker构建脚本,调整平台参数

This commit is contained in:
TsMask
2025-05-16 14:29:16 +08:00
parent b165562c2a
commit 952e55140b
3 changed files with 23 additions and 33 deletions

View File

@@ -11,9 +11,7 @@ fi
# Default Version
VERSION="1.0.0"
# Default Platform
PLATFORM="linux/amd64"
# Default Platform Architecture
PLATFORM_ARCH="amd64"
PLATFORM="amd64"
# Default System
SYSTEM="ubuntu22.04"
@@ -23,7 +21,7 @@ usage() {
echo
echo "Build Software Package OPTION:"
echo " -v, --version Specify the version"
echo " -p, --platform Specify the platform architecture (linux/amd64,linux/arm64)"
echo " -p, --platform Specify the platform architecture (amd64,arm64)"
echo " -s, --system Specify the system image (ubuntu22.04)"
echo " -h Display this help message"
echo
@@ -45,26 +43,18 @@ echo "Version: $VERSION"
# Determine if -p is passed in
if [ -n "$PLATFORM" ]; then
if [[ "$PLATFORM" != "linux/amd64" && "$PLATFORM" != "linux/arm64" ]]; then
echo "Error: platform can only be 'linux/amd64' or 'linux/arm64'."
case $PLATFORM in
amd64) ;;
arm64) ;;
*)
echo "Error: platform be: $PLATFORM"
echo "can only be 'amd64' , 'arm64'"
exit 1
fi
;;
esac
fi
echo "Platform: $PLATFORM"
# Get the platform architecture
get_platform_arch() {
if [[ "$PLATFORM" = "linux/amd64" ]]; then
echo "amd64"
elif [[ "$PLATFORM" = "linux/arm64" ]]; then
echo "arm64"
else
echo "unknown platform"
exit 1
fi
}
PLATFORM_ARCH=$(get_platform_arch)
# Determine if -s is passed in
if [ -n "$SYSTEM" ]; then
case $SYSTEM in
@@ -89,9 +79,9 @@ BuildPackagelDir=${RootDir}/pkg
# Compile the build directory
BuildDir=${RootDir}/tmp
# Release Package directory
ReleaseDir=${RootDir}/release/docker/${PLATFORM_ARCH}
ReleaseDir=${RootDir}/release/docker/${PLATFORM}
# Release Package name file
ReleaseFileName=omc-r${VERSION}-docker-${SYSTEM}-${PLATFORM_ARCH}
ReleaseFileName=omc-r${VERSION}-docker-${SYSTEM}-${PLATFORM}
# =================== file processing
@@ -131,7 +121,7 @@ docker_build() {
fi
# build omc
docker build --platform ${PLATFORM} --build-arg VERSION=${VERSION} -t omc:${VERSION} .
docker build --platform linux/${PLATFORM} --build-arg VERSION=${VERSION} -t omc:${VERSION} .
docker save omc:${VERSION} -o ${BuildDir}/${ReleaseFileName}/tar/omc_${VERSION}.tar
# tar package
@@ -148,7 +138,7 @@ docker_build() {
echo
echo "building omc..."
mkdir -p ${BuildDir}/${ReleaseFileName}/tar
cp -rf ${BuildPackagelDir}/docker/Dockerfile.${SYSTEM}.${PLATFORM_ARCH} ${BuildDir}/Dockerfile
cp -rf ${BuildPackagelDir}/docker/Dockerfile.${SYSTEM} ${BuildDir}/Dockerfile
cp -rf ${BuildPackagelDir}/docker/release/* ${BuildDir}/${ReleaseFileName}
cp -rf ${BuildLinuxDir} ${BuildDir}
ls -ls ${BuildDir}
@@ -156,4 +146,4 @@ app
docker_build
# bash build-docker.sh --version 2.2505.2 --platform linux/arm64 --system ubuntu22.04
# bash build-docker.sh --version 2.2505.2 --platform arm64 --system ubuntu22.04