Change Settings.Software and Settings.Version to build-time constants
Construct default Settings.Version using `git describe` (needs .git tree in builder) Version number can be overridden on make command line with argument `VERSION=foobar` Also include Settings.BuiltAt (unused by default but available for e.g. custom settings page) Use `make build` in Dockerfile instead of go `install`, for consistency Add **/keydump/, contrib/docker-compose/ and snap/ to .dockerignore for extra safety
This commit is contained in:
parent
34140ca77d
commit
4bcebe63f5
@ -1,7 +1,8 @@
|
||||
/bin
|
||||
/pkg
|
||||
/snap
|
||||
/contrib/pyinfra
|
||||
/.git
|
||||
/contrib/docker-compose
|
||||
/.gocache
|
||||
/**/secrets
|
||||
/keydump
|
||||
/**/keydump
|
||||
|
@ -5,11 +5,12 @@ ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update -qq && apt-get -y install build-essential postgresql-11 postgresql-server-dev-11 --no-install-recommends
|
||||
COPY --chown=builder:root Makefile /hockeypuck/
|
||||
COPY --chown=builder:root src /hockeypuck/src
|
||||
COPY --chown=builder:root .git /hockeypuck/.git
|
||||
ENV GOPATH=/hockeypuck
|
||||
USER builder
|
||||
WORKDIR /hockeypuck
|
||||
RUN make lint test test-postgresql
|
||||
RUN cd src/hockeypuck && go install hockeypuck/server/cmd/...
|
||||
RUN make build
|
||||
|
||||
|
||||
FROM debian:buster-slim
|
||||
|
8
Makefile
8
Makefile
@ -2,6 +2,8 @@ PROJECTPATH = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
export GOPATH := $(PROJECTPATH)
|
||||
export GOCACHE := $(GOPATH)/.gocache
|
||||
export SRCDIR := $(PROJECTPATH)src/hockeypuck
|
||||
VERSION ?= $(shell git describe --tags)
|
||||
TIMESTAMP = $(shell date -Iseconds)
|
||||
|
||||
project = hockeypuck
|
||||
|
||||
@ -74,7 +76,11 @@ define make-go-cmd-target
|
||||
$(eval cmd_target := $(cmd_name))
|
||||
|
||||
$(cmd_target):
|
||||
cd $(SRCDIR) && go install $(cmd_package)
|
||||
cd $(SRCDIR) && \
|
||||
go install -ldflags " \
|
||||
-X hockeypuck/server.Version=$(VERSION) \
|
||||
-X hockeypuck/server.BuiltAt=$(TIMESTAMP) \
|
||||
" $(cmd_package)
|
||||
|
||||
build: $(cmd_target)
|
||||
|
||||
|
@ -186,8 +186,9 @@ type Settings struct {
|
||||
|
||||
Contact string `toml:"contact"`
|
||||
Hostname string `toml:"hostname"`
|
||||
Software string `toml:"software"`
|
||||
Version string `toml:"version"`
|
||||
Software string
|
||||
Version string
|
||||
BuiltAt string
|
||||
|
||||
MaxResponseLen int `toml:"maxResponseLen"`
|
||||
}
|
||||
@ -197,6 +198,12 @@ const (
|
||||
DefaultLevelDBPath = "recon.db"
|
||||
)
|
||||
|
||||
var (
|
||||
Software = "Hockeypuck"
|
||||
Version = "~unreleased"
|
||||
BuiltAt string
|
||||
)
|
||||
|
||||
func DefaultSettings() Settings {
|
||||
metricsSettings := metrics.DefaultSettings()
|
||||
reconSettings := recon.DefaultSettings()
|
||||
@ -215,8 +222,9 @@ func DefaultSettings() Settings {
|
||||
Metrics: metricsSettings,
|
||||
OpenPGP: DefaultOpenPGP(),
|
||||
LogLevel: DefaultLogLevel,
|
||||
Software: "Hockeypuck",
|
||||
Version: "~unreleased",
|
||||
Software: Software,
|
||||
Version: Version,
|
||||
BuiltAt: BuiltAt,
|
||||
MaxResponseLen: DefaultMaxResponseLen,
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user