File tree Expand file tree Collapse file tree 3 files changed +9
-16
lines changed Expand file tree Collapse file tree 3 files changed +9
-16
lines changed Original file line number Diff line number Diff line change 1
1
FROM docker.io/library/golang:alpine as builder
2
2
3
- ARG PB_BUILD_VERSION
4
-
5
3
ARG CLI_VERSION=0.0.6
6
4
ARG CLI_PLATFORM=linux_amd64
7
5
@@ -13,7 +11,7 @@ RUN set -ex \
13
11
&& apk add --no-cache build-base ca-certificates curl \
14
12
&& go mod download \
15
13
&& go mod verify \
16
- && PB_BUILD_VERSION= "$PB_BUILD_VERSION" make build \
14
+ && make build \
17
15
&& chmod +x /build/out/pushbits \
18
16
&& curl -q -s -S -L -o /tmp/pbcli_${CLI_VERSION}.tar.gz https://github.com/pushbits/cli/releases/download/v${CLI_VERSION}/pbcli_${CLI_VERSION}_${CLI_PLATFORM}.tar.gz \
19
17
&& tar -C /usr/local/bin -xvf /tmp/pbcli_${CLI_VERSION}.tar.gz pbcli \
Original file line number Diff line number Diff line change @@ -5,15 +5,10 @@ TESTS_DIR := ./tests
5
5
GO_FILES := $(shell find . -type f \( -iname '* .go' \) )
6
6
GO_MODULE := github.com/pushbits/server
7
7
8
- PB_BUILD_VERSION ?= $(shell git describe --tags)
9
- ifeq ($(PB_BUILD_VERSION ) ,)
10
- _ := $(error Cannot determine build version)
11
- endif
12
-
13
8
.PHONY : build
14
9
build :
15
10
mkdir -p $(OUT_DIR )
16
- go build -ldflags=" -w -s -X main.version= $( PB_BUILD_VERSION ) " -o $(OUT_DIR ) /pushbits ./cmd/pushbits
11
+ go build -ldflags=" -w -s" -o $(OUT_DIR ) /pushbits ./cmd/pushbits
17
12
18
13
.PHONY : clean
19
14
clean :
@@ -63,7 +58,6 @@ swag: build
63
58
.PHONY : docker_build_dev
64
59
docker_build_dev :
65
60
podman build \
66
- --build-arg=PB_BUILD_VERSION=dev \
67
61
-t local/pushbits .
68
62
69
63
.PHONY : run_postgres_debug
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ package main
4
4
import (
5
5
"os"
6
6
"os/signal"
7
+ "runtime/debug"
7
8
"syscall"
8
9
9
10
"github.com/pushbits/server/internal/authentication/credentials"
@@ -15,8 +16,6 @@ import (
15
16
"github.com/pushbits/server/internal/runner"
16
17
)
17
18
18
- var version string
19
-
20
19
func setupCleanup (db * database.Database , dp * dispatcher.Dispatcher ) {
21
20
c := make (chan os.Signal , 2 )
22
21
signal .Notify (c , os .Interrupt , syscall .SIGTERM )
@@ -30,11 +29,13 @@ func setupCleanup(db *database.Database, dp *dispatcher.Dispatcher) {
30
29
}
31
30
32
31
func printStarupMessage () {
33
- if len ( version ) == 0 {
34
- log . L . Panic ( "Version not set" )
35
- } else {
36
- log . L . Printf ( "Starting PushBits %s" , version )
32
+ buildInfo , ok := debug . ReadBuildInfo ()
33
+ if ! ok {
34
+ log . L . Fatalln ( "Build info not available" )
35
+ return
37
36
}
37
+
38
+ log .L .Printf ("Starting PushBits %s" , buildInfo .Main .Version )
38
39
}
39
40
40
41
// @title PushBits Server API Documentation
You can’t perform that action at this time.
0 commit comments