feat: 添加Docker构建和管理脚本,优化构建流程
This commit is contained in:
100
pkg-docker.sh
Normal file
100
pkg-docker.sh
Normal file
@@ -0,0 +1,100 @@
|
||||
#!/bin/bash
|
||||
|
||||
# front-end Catalog
|
||||
WebDir=/root/omc.git/fe.ems.vue3
|
||||
WebBranch=main
|
||||
# back-end catalog
|
||||
ApiDir=/root/omc.git/be.ems
|
||||
ApiBranch=main
|
||||
# Package Catalog
|
||||
BuildDir=/root/omc.git/build.ems
|
||||
BuildTmpDir=/root/omc.git/build.ems/tmp
|
||||
# Default Version Value
|
||||
VERSION="2.2503.2"
|
||||
|
||||
# usage
|
||||
usage() {
|
||||
echo "Usage: bash $0 [OPTION]"
|
||||
echo
|
||||
echo "Build Software Package OPTION:"
|
||||
echo " -v Specify the version"
|
||||
echo " -webBranch Web Branch ($WebBranch)"
|
||||
echo " -apiBranch Api Branch ($ApiBranch)"
|
||||
echo " -h Display this help message"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
# Read command line arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-v) VERSION="$2"; shift 2 ;;
|
||||
-webBranch) WebBranch="$2"; shift 2 ;;
|
||||
-apiBranch) ApiBranch="$2"; shift 2 ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
done
|
||||
rm -rf ${BuildTmpDir} && mkdir -p ${BuildTmpDir}
|
||||
|
||||
# =================== Web
|
||||
echo
|
||||
cd $WebDir
|
||||
git checkout .
|
||||
git pull
|
||||
git checkout $WebBranch
|
||||
git pull
|
||||
|
||||
# cp -rf $WebDir $BuildTmpDir/omc_web
|
||||
mkdir -p $BuildTmpDir/omc_web
|
||||
cp -rf $WebDir/src $BuildTmpDir/omc_web
|
||||
cp -rf $WebDir/public $BuildTmpDir/omc_web
|
||||
cp -rf $WebDir/index.html $BuildTmpDir/omc_web
|
||||
cp -rf $WebDir/.env.production $BuildTmpDir/omc_web
|
||||
cp -rf $WebDir/.env.development $BuildTmpDir/omc_web
|
||||
cp -rf $WebDir/package-lock.json $BuildTmpDir/omc_web
|
||||
cp -rf $WebDir/package.json $BuildTmpDir/omc_web
|
||||
cp -rf $WebDir/tsconfig.json $BuildTmpDir/omc_web
|
||||
cp -rf $WebDir/tsconfig.node.json $BuildTmpDir/omc_web
|
||||
cp -rf $WebDir/vite.config.ts $BuildTmpDir/omc_web
|
||||
echo "===> web source code to $BuildTmpDir/omc_web"
|
||||
|
||||
# =================== Api
|
||||
echo
|
||||
cd $ApiDir
|
||||
git checkout .
|
||||
git pull
|
||||
git checkout $ApiBranch
|
||||
git pull
|
||||
|
||||
# cp -rf $ApiDir $BuildTmpDir/omc_api
|
||||
mkdir -p $BuildTmpDir/omc_api
|
||||
cp -rf $ApiDir/features $BuildTmpDir/omc_api
|
||||
cp -rf $ApiDir/lib $BuildTmpDir/omc_api
|
||||
cp -rf $ApiDir/src $BuildTmpDir/omc_api
|
||||
cp -rf $ApiDir/sshsvc $BuildTmpDir/omc_api
|
||||
cp -rf $ApiDir/swagger_docs $BuildTmpDir/omc_api
|
||||
cp -rf $ApiDir/go.sum $BuildTmpDir/omc_api
|
||||
cp -rf $ApiDir/go.mod $BuildTmpDir/omc_api
|
||||
cp -rf $ApiDir/main.go $BuildTmpDir/omc_api
|
||||
echo "===> omc source code to $BuildTmpDir/omc_api"
|
||||
|
||||
# Vendor Database
|
||||
output=$BuildDir/linux/usr/local/etc/omc
|
||||
dirs="database default vendor"
|
||||
for v in ${dirs}; do
|
||||
rm -rf ${output}/${v}
|
||||
cp -rf ${ApiDir}/build/${v} ${output}/${v}
|
||||
done
|
||||
echo
|
||||
echo "===> vendor data copy to $output"
|
||||
|
||||
|
||||
# =================== build docker image
|
||||
echo
|
||||
bash $BuildDir/build-docker.sh --version $VERSION --platform linux/amd64 --system ubuntu22.04
|
||||
|
||||
# Compile the front-end and back-end and then package the version
|
||||
# bash pkg.sh --web -webBranch main --api -apiBranch main -v 2.2503.2
|
||||
# bash pkg.sh --web --api -v 2.2503.2
|
||||
# bash pkg.sh --api -apiBranch main -v 2.2503.2
|
||||
# Packaged version of just the last compiled file/build directory
|
||||
# bash pkg.sh -v 2.2503.2
|
||||
Reference in New Issue
Block a user