From 952e55140b9e44ddedb942b0cc7e68db89a249ba Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 16 May 2025 14:29:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0Docker=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E8=84=9A=E6=9C=AC=EF=BC=8C=E8=B0=83=E6=95=B4=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-docker.sh | 40 +++++++------------ pkg-docker.sh | 16 ++++---- ...untu22.04.amd64 => Dockerfile.ubuntu22.04} | 0 3 files changed, 23 insertions(+), 33 deletions(-) rename pkg/docker/{Dockerfile.ubuntu22.04.amd64 => Dockerfile.ubuntu22.04} (100%) diff --git a/build-docker.sh b/build-docker.sh index 6df52f3..e5a7e08 100644 --- a/build-docker.sh +++ b/build-docker.sh @@ -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 diff --git a/pkg-docker.sh b/pkg-docker.sh index 7eb50f7..1b9e7bc 100644 --- a/pkg-docker.sh +++ b/pkg-docker.sh @@ -2,13 +2,13 @@ # front-end Catalog WebDir=/root/omc.git/fe.ems.vue3 -WebBranch=main +WebBranch=lichang # back-end catalog ApiDir=/root/omc.git/be.ems -ApiBranch=main +ApiBranch=lichang # Package Catalog BuildDir=/root/omc.git/build.ems -BuildBranch=main +BuildBranch=lichang BuildTmpDir=/root/omc.git/build.ems/tmp # Default Version Value VERSION="2.2505.2" @@ -34,8 +34,6 @@ while [[ $# -gt 0 ]]; do *) usage ;; esac done -# clear tmp dir -rm -rf ${BuildTmpDir} && mkdir -p ${BuildTmpDir} # =================== build branch echo @@ -44,6 +42,9 @@ git checkout . git pull git checkout $BuildBranch git pull +# clear tmp dir +rm -rf ${BuildTmpDir} && mkdir -p ${BuildTmpDir} +echo "===> build checkout directory: $BuildDir" # =================== Web echo @@ -99,8 +100,7 @@ echo "===> vendor data copy to $output" # =================== build docker image 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 -# bash pkg-docker.sh -webBranch main -apiBranch main -v 2.2503.2 -# bash pkg-docker.sh -v 2.2503.2 +# bash pkg-docker.sh -v 2.2505.2 diff --git a/pkg/docker/Dockerfile.ubuntu22.04.amd64 b/pkg/docker/Dockerfile.ubuntu22.04 similarity index 100% rename from pkg/docker/Dockerfile.ubuntu22.04.amd64 rename to pkg/docker/Dockerfile.ubuntu22.04