dockerfiles/anylink/build.sh

48 lines
823 B
Bash
Raw Normal View History

2021-06-08 20:45:26 +08:00
#!/bin/env bash
set -x
function RETVAL() {
rt=$1
if [ $rt != 0 ]; then
echo $rt
exit 1
fi
}
#当前目录
cpath=$(pwd)
echo "编译前端项目"
cd $cpath/web
#国内可替换源加快速度
2021-07-05 18:23:27 +08:00
npx browserslist@latest --update-db
2021-06-08 20:45:26 +08:00
npm install --registry=https://registry.npm.taobao.org
#npm install
2021-07-05 18:23:27 +08:00
npm run build
RETVAL $?
echo "编译二进制文件"
cd $cpath/server
rm -rf ui
cp -rf $cpath/web/ui .
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
cp -r server/bridge-init.sh $deploy
cp -r systemd $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"