108 lines
2.8 KiB
Bash
108 lines
2.8 KiB
Bash
#!/bin/bash
|
|
|
|
# front-end Catalog
|
|
WebDir=/root/omc.git/fe.ems.vue3
|
|
WebBranch=lichang
|
|
# back-end catalog
|
|
ApiDir=/root/omc.git/be.ems
|
|
ApiBranch=lichang
|
|
# Package Catalog
|
|
BuildDir=/root/omc.git/build.ems
|
|
BuildBranch=lichang
|
|
BuildTmpDir=/root/omc.git/build.ems/tmp
|
|
# Default Version Value
|
|
VERSION="2.2505.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
|
|
|
|
# =================== build branch
|
|
echo
|
|
cd $BuildDir
|
|
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
|
|
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.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 -v $VERSION -p amd64 -s ubuntu22.04
|
|
bash $BuildDir/build-docker.sh -v $VERSION -p amd64 -s alpine3.20
|
|
|
|
# Compile the front-end and back-end and then package the version
|
|
# bash pkg-docker.sh -v 2.2505.2
|