From fc1e15bf3117a1c2f6061e13b97e8188e4779a0e Mon Sep 17 00:00:00 2001 From: naiba Date: Thu, 29 Oct 2020 11:20:32 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20build=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile.dashboard | 5 ++--- resource/template/common/footer.html | 2 +- service/dao/dao.go | 6 ++++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Dockerfile.dashboard b/Dockerfile.dashboard index 6fc79af..bd2ae4e 100644 --- a/Dockerfile.dashboard +++ b/Dockerfile.dashboard @@ -1,11 +1,10 @@ FROM golang:alpine AS binarybuilder RUN apk --no-cache --no-progress add \ - gcc \ - musl-dev + gcc git musl-dev WORKDIR /dashboard COPY . . RUN cd cmd/dashboard \ - && go build -o app -ldflags="-s -w" + && go build -o app -ldflags="-s -w -X github.com/p14yground/nezha/service/dao.Version=`git rev-parse HEAD`" FROM alpine:latest RUN apk --no-cache --no-progress add \ diff --git a/resource/template/common/footer.html b/resource/template/common/footer.html index c11e475..9fb31be 100644 --- a/resource/template/common/footer.html +++ b/resource/template/common/footer.html @@ -1,7 +1,7 @@ {{define "common/footer"}} diff --git a/service/dao/dao.go b/service/dao/dao.go index aa188ae..35f1af1 100644 --- a/service/dao/dao.go +++ b/service/dao/dao.go @@ -28,6 +28,12 @@ var ServerLock sync.RWMutex // Version .. var Version = "debug" +func init() { + if len(Version) > 7 { + Version = Version[:7] + } +} + // SendCommand .. func SendCommand(cmd *pb.Command) { ServerLock.RLock()