]> git.r.bdr.sh - rbdr/mobius/commitdiff
Fix missing version in Docker and Makefile build
authorJeff Halter <redacted>
Sat, 27 Jul 2024 22:40:57 +0000 (15:40 -0700)
committerJeff Halter <redacted>
Sat, 27 Jul 2024 22:40:57 +0000 (15:40 -0700)
Dockerfile
Makefile
cmd/mobius-hotline-server/main.go

index ee33b0e9849ffbc623d63b03abcd3b3344396fce..f5b2af69cbdaf74185d34752a7f2f5ecee50d799 100644 (file)
@@ -3,7 +3,7 @@ FROM golang:1.22 AS builder
 WORKDIR /app
 COPY . .
 
 WORKDIR /app
 COPY . .
 
-RUN CGO_ENABLED=0 go build -o /app/server cmd/mobius-hotline-server/main.go && chmod a+x /app/server
+RUN CGO_ENABLED=0 go build -ldflags "-X main.version=$(git describe --exact-match --tags)" -o /app/server cmd/mobius-hotline-server/main.go && chmod a+x /app/server
 
 FROM scratch
 
 
 FROM scratch
 
index 2832baacbc8ddd67b6cb2668a893b94766aec910..54a86311fade589fe3316439d99504e5fb4126c2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,2 @@
 server:
 server:
-       go build -o mobius-hotline-server cmd/mobius-hotline-server/main.go
-
-client:
-       go build -o mobius-hotline-client cmd/mobius-hotline-client/main.go
\ No newline at end of file
+       go build -ldflags "-X main.version=$$(git describe --exact-match --tags || echo "dev" ) -X main.commit=$$(git rev-parse --short HEAD)" -o mobius-hotline-server cmd/mobius-hotline-server/main.go
index 1390dda34573e1618a72f0eb54fe615bd10ec3dd..e4e095447e670bf2cc00fca14e6add54e53d1474 100644 (file)
@@ -24,7 +24,6 @@ var cfgTemplate embed.FS
 var (
        version = "dev"
        commit  = "none"
 var (
        version = "dev"
        commit  = "none"
-       date    = "unknown"
 )
 
 func main() {
 )
 
 func main() {
@@ -45,7 +44,7 @@ func main() {
        flag.Parse()
 
        if *printVersion {
        flag.Parse()
 
        if *printVersion {
-               fmt.Printf("mobius-hotline-server %s, commit %s, built on %s\n", version, commit, date)
+               fmt.Printf("mobius-hotline-server version %s, commit %s\n", version, commit)
                os.Exit(0)
        }
 
                os.Exit(0)
        }