mirror of https://github.com/bjdgyc/anylink.git
修改 docker 编译
This commit is contained in:
parent
10a335dc3d
commit
f9ff92d73d
|
@ -18,20 +18,20 @@ jobs:
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
# - uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
# with:
|
with:
|
||||||
# node-version: '16'
|
node-version: '16'
|
||||||
# cache: 'yarn'
|
cache: 'yarn'
|
||||||
# cache-dependency-path: 'web/yarn.lock'
|
cache-dependency-path: 'web/yarn.lock'
|
||||||
# - uses: actions/setup-go@v4
|
- name: Build web
|
||||||
# with:
|
working-directory: web
|
||||||
# go-version: '1.20'
|
run: |
|
||||||
# cache-dependency-path: 'server/go.sum'
|
yarn install
|
||||||
# - name: Build web
|
yarn run build
|
||||||
# working-directory: web
|
# - uses: actions/setup-go@v4
|
||||||
# run: |
|
# with:
|
||||||
# yarn install
|
# go-version: '1.20'
|
||||||
# yarn run build
|
# cache-dependency-path: 'server/go.sum'
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
# https://github.com/docker/setup-qemu-action
|
# https://github.com/docker/setup-qemu-action
|
||||||
|
@ -54,9 +54,6 @@ jobs:
|
||||||
echo "APP_VER=$appVer" >> $GITHUB_ENV
|
echo "APP_VER=$appVer" >> $GITHUB_ENV
|
||||||
echo "commitId=$commitId" >> $GITHUB_ENV
|
echo "commitId=$commitId" >> $GITHUB_ENV
|
||||||
|
|
||||||
mkdir web/ui
|
|
||||||
touch web/ui/a.txt
|
|
||||||
|
|
||||||
#cd server;go mod tidy
|
#cd server;go mod tidy
|
||||||
|
|
||||||
- name: Build and push
|
- name: Build and push
|
||||||
|
@ -67,19 +64,18 @@ jobs:
|
||||||
#cache-to: type=gha,mode=max
|
#cache-to: type=gha,mode=max
|
||||||
context: .
|
context: .
|
||||||
file: ./docker/Dockerfile
|
file: ./docker/Dockerfile
|
||||||
#platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
platforms: linux/amd64
|
|
||||||
build-args: |
|
build-args: |
|
||||||
appVer=${{ env.APP_VER }}
|
appVer=${{ env.APP_VER }}
|
||||||
commitId=${{ env.commitId }}
|
commitId=${{ env.commitId }}
|
||||||
#tags: bjdgyc/anylink:latest,bjdgyc/anylink:${{ env.APP_VER }}
|
#tags: bjdgyc/anylink:latest,bjdgyc/anylink:${{ env.APP_VER }}
|
||||||
tags: bjdgyc/anylink:${{ env.APP_VER }}
|
tags: bjdgyc/anylink:${{ env.APP_VER }}
|
||||||
|
|
||||||
# - name: Docker Build binary
|
- name: Build Copy binary
|
||||||
# shell: bash
|
shell: bash
|
||||||
# run: |
|
run: |
|
||||||
# #sudo apt-get install -y -q gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
|
#sudo apt-get install -y -q gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
|
||||||
# bash release.sh
|
bash release.sh
|
||||||
|
|
||||||
# Docker:
|
# Docker:
|
||||||
# name: build-docker
|
# name: build-docker
|
||||||
|
|
20
build.sh
20
build.sh
|
@ -11,7 +11,7 @@ function RETVAL() {
|
||||||
|
|
||||||
#当前目录
|
#当前目录
|
||||||
cpath=$(pwd)
|
cpath=$(pwd)
|
||||||
|
#ver=`cat server/base/app_ver.go | grep APP_VER | awk '{print $3}' | sed 's/"//g'`
|
||||||
ver=$(cat version)
|
ver=$(cat version)
|
||||||
echo "当前版本 $ver"
|
echo "当前版本 $ver"
|
||||||
|
|
||||||
|
@ -40,6 +40,24 @@ go build -o anylink "$flags" -ldflags "$ldflags"
|
||||||
|
|
||||||
cd $cpath
|
cd $cpath
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
echo "整理部署文件"
|
||||||
|
deploy="anylink-deploy"
|
||||||
|
rm -rf $deploy ${deploy}.tar.gz
|
||||||
|
mkdir $deploy
|
||||||
|
mkdir $deploy/log
|
||||||
|
|
||||||
|
cp -r server/anylink $deploy
|
||||||
|
cp -r server/bridge-init.sh $deploy
|
||||||
|
cp -r server/conf $deploy
|
||||||
|
|
||||||
|
cp -r systemd $deploy
|
||||||
|
cp -r LICENSE $deploy
|
||||||
|
cp -r home $deploy
|
||||||
|
|
||||||
|
tar zcvf ${deploy}.tar.gz $deploy
|
||||||
|
|
||||||
#注意使用root权限运行
|
#注意使用root权限运行
|
||||||
#cd anylink-deploy
|
#cd anylink-deploy
|
||||||
#sudo ./anylink --conf="conf/server.toml"
|
#sudo ./anylink --conf="conf/server.toml"
|
||||||
|
|
|
@ -36,6 +36,7 @@ COPY --from=builder_golang /server/anylink /app/
|
||||||
COPY docker/docker_entrypoint.sh /app/
|
COPY docker/docker_entrypoint.sh /app/
|
||||||
COPY ./server/bridge-init.sh /app/
|
COPY ./server/bridge-init.sh /app/
|
||||||
COPY ./server/conf /app/conf
|
COPY ./server/conf /app/conf
|
||||||
|
COPY ./systemd /app/systemd
|
||||||
COPY ./README.md /app/README.md
|
COPY ./README.md /app/README.md
|
||||||
COPY ./LICENSE /app/LICENSE
|
COPY ./LICENSE /app/LICENSE
|
||||||
COPY ./home /app/home
|
COPY ./home /app/home
|
||||||
|
|
|
@ -8,7 +8,7 @@ if [[ $CN == "yes" ]]; then
|
||||||
export GOPROXY=https://goproxy.cn
|
export GOPROXY=https://goproxy.cn
|
||||||
fi
|
fi
|
||||||
|
|
||||||
apk add tzdata gcc musl-dev
|
apk add tzdata gcc musl-dev upx
|
||||||
|
|
||||||
uname -a
|
uname -a
|
||||||
env
|
env
|
||||||
|
@ -20,12 +20,13 @@ go mod tidy
|
||||||
|
|
||||||
echo "start build"
|
echo "start build"
|
||||||
|
|
||||||
#-extldflags '-static'
|
ldflags="-s -w -extldflags '-static' -X main.appVer=$appVer -X main.commitId=$commitId -X main.buildDate=$(date -Iseconds)"
|
||||||
|
|
||||||
ldflags="-s -w -extldflags \"-static\" -X main.appVer=$appVer -X main.commitId=$commitId -X main.buildDate=$(date -Iseconds)"
|
|
||||||
|
|
||||||
go build -o anylink -trimpath -ldflags "$ldflags"
|
go build -o anylink -trimpath -ldflags "$ldflags"
|
||||||
|
|
||||||
ls -l /server/
|
ls -lh /server/
|
||||||
|
|
||||||
|
# 压缩文件
|
||||||
|
upx -9 -k anylink
|
||||||
|
|
||||||
/server/anylink -v
|
/server/anylink -v
|
||||||
|
|
63
release.sh
63
release.sh
|
@ -14,62 +14,33 @@ function RETVAL() {
|
||||||
#当前目录
|
#当前目录
|
||||||
cpath=$(pwd)
|
cpath=$(pwd)
|
||||||
|
|
||||||
#ver=`cat server/base/app_ver.go | grep APP_VER | awk '{print $3}' | sed 's/"//g'`
|
|
||||||
ver=$(cat version)
|
ver=$(cat version)
|
||||||
echo "当前版本 $ver"
|
echo "当前版本 $ver"
|
||||||
|
|
||||||
echo "编译前端项目"
|
mkdir archive anylink-deploy
|
||||||
cd $cpath/web
|
|
||||||
#国内可替换源加快速度
|
|
||||||
#npx browserslist@latest --update-db
|
|
||||||
yarn install
|
|
||||||
yarn run build
|
|
||||||
RETVAL $?
|
|
||||||
rm -rf $cpath/server/ui
|
|
||||||
cp -rf $cpath/web/ui . $cpath/server/ui
|
|
||||||
|
|
||||||
echo "编译二进制文件"
|
function archive() {
|
||||||
cd $cpath/server
|
os=$1
|
||||||
|
arch=$2
|
||||||
|
echo "整理部署文件 $os $arch"
|
||||||
|
|
||||||
# -tags osusergo,netgo,sqlite_omit_load_extension
|
deploy="anylink-$ver-$os-$arch"
|
||||||
flags="-trimpath"
|
docker container create --platform $os/$arch --name $deploy bjdgyc/anylink
|
||||||
ldflags="-s -w -extldflags '-static' -X main.appVer=$ver -X main.commitId=$(git rev-parse HEAD) -X main.date=$(date --iso-8601=seconds)"
|
rm -rf anylink-deploy/*
|
||||||
|
docker cp -a $deploy:/app/ ./anylink-deploy/
|
||||||
|
ls -lh anylink-deploy
|
||||||
|
tar zcf ${deploy}.tar.gz anylink-deploy
|
||||||
|
mv ${deploy}.tar.gz archive/
|
||||||
|
}
|
||||||
|
|
||||||
#github action
|
|
||||||
gopath=$(go env GOPATH)
|
|
||||||
#go mod tidy
|
|
||||||
|
|
||||||
# alpine3
|
echo "copy二进制文件"
|
||||||
apk add gcc musl-dev
|
|
||||||
|
|
||||||
#使用 musl-dev 编译
|
archive linux amd64
|
||||||
docker run -q --rm -v $PWD:/app -v $gopath:/go -w /app --platform=linux/amd64 \
|
archive linux arm64
|
||||||
golang:1.20-alpine3.19 go build -o anylink_amd64 $flags -ldflags "$ldflags"
|
|
||||||
./anylink_amd64 -v
|
|
||||||
#arm64编译
|
|
||||||
docker run -q --rm -v $PWD:/app -v $gopath:/go -w /app --platform=linux/arm64 \
|
|
||||||
golang:1.20-alpine3.19 go build -o anylink_arm64 $flags -ldflags "$ldflags"
|
|
||||||
./anylink_arm64 -v
|
|
||||||
|
|
||||||
exit 0
|
ls -lh archive
|
||||||
|
|
||||||
cd $cpath
|
|
||||||
|
|
||||||
echo "整理部署文件"
|
|
||||||
deploy="anylink-deploy"
|
|
||||||
rm -rf $deploy ${deploy}.tar.gz
|
|
||||||
mkdir $deploy
|
|
||||||
mkdir $deploy/log
|
|
||||||
|
|
||||||
cp -r server/anylink $deploy
|
|
||||||
cp -r server/bridge-init.sh $deploy
|
|
||||||
cp -r server/conf $deploy
|
|
||||||
|
|
||||||
cp -r systemd $deploy
|
|
||||||
cp -r LICENSE $deploy
|
|
||||||
cp -r home $deploy
|
|
||||||
|
|
||||||
tar zcvf ${deploy}.tar.gz $deploy
|
|
||||||
|
|
||||||
#注意使用root权限运行
|
#注意使用root权限运行
|
||||||
#cd anylink-deploy
|
#cd anylink-deploy
|
||||||
|
|
|
@ -0,0 +1,58 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#github action release.sh
|
||||||
|
|
||||||
|
set -x
|
||||||
|
function RETVAL() {
|
||||||
|
rt=$1
|
||||||
|
if [ $rt != 0 ]; then
|
||||||
|
echo $rt
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#当前目录
|
||||||
|
cpath=$(pwd)
|
||||||
|
|
||||||
|
echo "copy二进制文件"
|
||||||
|
cd $cpath/server
|
||||||
|
# -tags osusergo,netgo,sqlite_omit_load_extension
|
||||||
|
flags="-trimpath"
|
||||||
|
ldflags="-s -w -extldflags '-static' -X main.appVer=$ver -X main.commitId=$(git rev-parse HEAD) -X main.date=$(date --iso-8601=seconds)"
|
||||||
|
#github action
|
||||||
|
gopath=$(go env GOPATH)
|
||||||
|
go mod tidy
|
||||||
|
# alpine3
|
||||||
|
apk add gcc musl-dev
|
||||||
|
#使用 musl-dev 编译
|
||||||
|
docker run -q --rm -v $PWD:/app -v $gopath:/go -w /app --platform=linux/amd64 \
|
||||||
|
golang:1.20-alpine3.19 go build -o anylink_amd64 $flags -ldflags "$ldflags"
|
||||||
|
./anylink_amd64 -v
|
||||||
|
#arm64编译
|
||||||
|
docker run -q --rm -v $PWD:/app -v $gopath:/go -w /app --platform=linux/arm64 \
|
||||||
|
golang:1.20-alpine3.19 go build -o anylink_arm64 $flags -ldflags "$ldflags"
|
||||||
|
./anylink_arm64 -v
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
cd $cpath
|
||||||
|
|
||||||
|
echo "整理部署文件"
|
||||||
|
deploy="anylink-deploy"
|
||||||
|
rm -rf $deploy ${deploy}.tar.gz
|
||||||
|
mkdir $deploy
|
||||||
|
mkdir $deploy/log
|
||||||
|
|
||||||
|
cp -r server/anylink $deploy
|
||||||
|
cp -r server/bridge-init.sh $deploy
|
||||||
|
cp -r server/conf $deploy
|
||||||
|
|
||||||
|
cp -r systemd $deploy
|
||||||
|
cp -r LICENSE $deploy
|
||||||
|
cp -r home $deploy
|
||||||
|
|
||||||
|
tar zcvf ${deploy}.tar.gz $deploy
|
||||||
|
|
||||||
|
#注意使用root权限运行
|
||||||
|
#cd anylink-deploy
|
||||||
|
#sudo ./anylink --conf="conf/server.toml"
|
Loading…
Reference in New Issue