dockerfiles/anylink/build.sh

61 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2022-11-10 15:53:48 +08:00
#!/bin/bash
2021-06-08 20:45:26 +08:00
set -x
function RETVAL() {
rt=$1
if [ $rt != 0 ]; then
echo $rt
exit 1
fi
}
#当前目录
cpath=$(pwd)
2023-08-08 17:35:40 +08:00
ver=`cat server/base/app_ver.go | grep APP_VER | awk '{print $3}' | sed 's/"//g'`
echo "当前版本 $ver"
2021-06-08 20:45:26 +08:00
echo "编译前端项目"
cd $cpath/web
#国内可替换源加快速度
2021-08-02 20:41:35 +08:00
#npx browserslist@latest --update-db
2022-04-07 16:33:16 +08:00
#npm install --registry=https://registry.npm.taobao.org
2021-06-08 20:45:26 +08:00
#npm install
2022-04-07 16:33:16 +08:00
#npm run build
2023-04-26 22:17:10 +08:00
yarn install --registry=https://registry.npmmirror.com
2022-04-07 16:33:16 +08:00
yarn run build
2023-04-26 22:17:10 +08:00
2021-07-05 18:23:27 +08:00
RETVAL $?
echo "编译二进制文件"
cd $cpath/server
rm -rf ui
cp -rf $cpath/web/ui .
2021-08-02 20:41:35 +08:00
#国内可替换源加快速度
export GOPROXY=https://goproxy.io
2022-07-04 15:03:22 +08:00
go mod tidy
2021-07-05 18:23:27 +08:00
go build -v -o anylink -ldflags "-X main.CommitId=$(git rev-parse HEAD)"
2021-06-08 20:45:26 +08:00
RETVAL $?
cd $cpath
echo "整理部署文件"
deploy="anylink-deploy"
2021-07-05 18:23:27 +08:00
rm -rf $deploy ${deploy}.tar.gz
2021-06-08 20:45:26 +08:00
mkdir $deploy
cp -r server/anylink $deploy
2023-04-26 22:17:10 +08:00
#cp -r server/bridge-init.sh $deploy
2021-08-02 20:41:35 +08:00
cp -r server/conf $deploy
2021-06-08 20:45:26 +08:00
cp -r systemd $deploy
2021-12-31 20:21:26 +08:00
cp -r LICENSE $deploy
2021-07-05 18:23:27 +08:00
tar zcvf ${deploy}.tar.gz $deploy
2021-06-08 20:45:26 +08:00
#注意使用root权限运行
#cd anylink-deploy
#sudo ./anylink --conf="conf/server.toml"