From 1234ee32e40adb9abc277dac8bce83988090125d Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Fri, 4 Aug 2017 14:10:23 +0100 Subject: [PATCH] close #186 --- Dockerfile | 3 ++- cmd/filemanager/main.go | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 91383d60..90f5fb95 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,8 @@ RUN apk add --no-cache git RUN go get ./... WORKDIR /go/src/github.com/hacdias/filemanager/cmd/filemanager -RUN go install +RUN go build -ldflags "-X main.version=$(git tag -l --points-at HEAD)" +RUN mv filemanager /go/bin/filemanager FROM alpine:latest COPY --from=0 /go/bin/filemanager /usr/local/bin/filemanager diff --git a/cmd/filemanager/main.go b/cmd/filemanager/main.go index 149ef844..65748d5e 100644 --- a/cmd/filemanager/main.go +++ b/cmd/filemanager/main.go @@ -87,10 +87,13 @@ func setupViper() { } func printVersion() { + version = strings.TrimSpace(version) + if version == "" { fmt.Println("filemanager is at an untracked version") } else { - fmt.Println("filemanager", version) + version = strings.TrimPrefix(version, "v") + fmt.Println("filemanager version", version) } os.Exit(0)