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

View File

@@ -2,13 +2,13 @@
# front-end Catalog # front-end Catalog
WebDir=/root/omc.git/fe.ems.vue3 WebDir=/root/omc.git/fe.ems.vue3
WebBranch=main WebBranch=lichang
# back-end catalog # back-end catalog
ApiDir=/root/omc.git/be.ems ApiDir=/root/omc.git/be.ems
ApiBranch=main ApiBranch=lichang
# Package Catalog # Package Catalog
BuildDir=/root/omc.git/build.ems BuildDir=/root/omc.git/build.ems
BuildBranch=main BuildBranch=lichang
BuildTmpDir=/root/omc.git/build.ems/tmp BuildTmpDir=/root/omc.git/build.ems/tmp
# Default Version Value # Default Version Value
VERSION="2.2505.2" VERSION="2.2505.2"
@@ -34,8 +34,6 @@ while [[ $# -gt 0 ]]; do
*) usage ;; *) usage ;;
esac esac
done done
# clear tmp dir
rm -rf ${BuildTmpDir} && mkdir -p ${BuildTmpDir}
# =================== build branch # =================== build branch
echo echo
@@ -44,6 +42,9 @@ git checkout .
git pull git pull
git checkout $BuildBranch git checkout $BuildBranch
git pull git pull
# clear tmp dir
rm -rf ${BuildTmpDir} && mkdir -p ${BuildTmpDir}
echo "===> build checkout directory: $BuildDir"
# =================== Web # =================== Web
echo echo
@@ -99,8 +100,7 @@ echo "===> vendor data copy to $output"
# =================== build docker image # =================== build docker image
echo echo
bash $BuildDir/build-docker.sh --version $VERSION --platform linux/amd64 --system ubuntu22.04 bash $BuildDir/build-docker.sh -v $VERSION -p amd64 -s ubuntu22.04
# Compile the front-end and back-end and then package the version # Compile the front-end and back-end and then package the version
# bash pkg-docker.sh -webBranch main -apiBranch main -v 2.2503.2 # bash pkg-docker.sh -v 2.2505.2
# bash pkg-docker.sh -v 2.2503.2