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
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
var (
version = "dev"
commit = "none"
- date = "unknown"
)
func main() {
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)
}