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)