调整为容器化编译

This commit is contained in:
lwch
2021-10-18 15:07:43 +08:00
parent 4136eae5c2
commit 63f217402c
5 changed files with 156 additions and 26 deletions
+8 -14
View File
@@ -1,17 +1,11 @@
#!/bin/sh
VERSION="0.5.0"
HASH=`git log -n1 --pretty=format:%h`
REVERSION=`git log --oneline|wc -l|tr -d ' '`
BUILD_TIME=`date +'%Y-%m-%d %H:%M:%S'`
LDFLAGS="-X 'main.gitHash=$HASH'
-X 'main.gitReversion=$REVERSION'
-X 'main.buildTime=$BUILD_TIME'
-X 'main.version=$VERSION'"
VERSION=0.5.0
go run contrib/bindata/main.go -pkg shell -o code/client/tunnel/shell/assets.go \
-prefix html/shell "$@" html/shell/...
go run contrib/bindata/main.go -pkg dashboard -o code/client/dashboard/assets.go \
-prefix html/dashboard "$@" html/dashboard/...
CGO_ENABLED=0 go build -ldflags "$LDFLAGS" -o bin/np-svr code/server/*.go
CGO_ENABLED=0 go build -ldflags "$LDFLAGS" -o bin/np-cli code/client/*.go
docker build -t natpass -f contrib/build/Dockerfile .
docker run -it --rm \
-v `pwd`:/build \
-v $HOME/.cache/go-build:/root/.cache/go-build \
-v $HOME/go/pkg/mod:/root/go/pkg/mod \
-e BUILD_VERSION=$VERSION \
natpass /build/contrib/build/build