add Dockerfile and build script

This commit is contained in:
2021-12-20 21:43:20 +00:00
parent 65d6fbe457
commit 12c3b5f784
3 changed files with 41 additions and 10 deletions

View File

@ -1,12 +1,17 @@
BUILD_HASH := $(shell git describe --always --tags --long)
LDFLAGS := "-X main.version=${BUILD_HASH} -s -w"
COMMIT = $(shell git describe --always --tags --long --dirty)
RELEASE ?= $(COMMIT)
LDFLAGS := -X main.version=$(RELEASE)
ifdef STATIC
LDFLAGS += -w -s -extldflags=-static
export CGO_ENABLED=0
endif
all: fmt install
fmt:
go fmt ./...
.PHONY: install
install:
go fmt ./...
go install -ldflags ${LDFLAGS} ./...
.PHONY: build
build:
go fmt ./...
go build -ldflags ${LDFLAGS} ./...
go install -ldflags "${LDFLAGS}" ./...