2019-10-03 19:30:04 +00:00
|
|
|
VERSION := $(shell git rev-parse --short HEAD)
|
|
|
|
BUILDTIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
|
|
|
|
BUILDUSER := $(shell whoami)
|
|
|
|
BUILDHOST := $(shell hostname -s)
|
|
|
|
BUILDARCH := $(shell uname -m)
|
2019-10-25 16:17:14 +00:00
|
|
|
APPNAME := merp
|
2019-10-03 19:30:04 +00:00
|
|
|
|
|
|
|
GOLDFLAGS += -X main.Version=$(VERSION)
|
|
|
|
GOLDFLAGS += -X main.Buildtime=$(BUILDTIME)
|
|
|
|
GOLDFLAGS += -X main.Builduser=$(BUILDUSER)@$(BUILDHOST)
|
|
|
|
GOLDFLAGS += -X main.Buildarch=$(BUILDARCH)
|
2019-10-25 16:17:14 +00:00
|
|
|
GOLDFLAGS += -X main.Appname=$(APPNAME)
|
2019-10-03 19:30:04 +00:00
|
|
|
GOFLAGS = -ldflags "$(GOLDFLAGS)"
|
|
|
|
|
|
|
|
default: run
|
|
|
|
|
|
|
|
run: build
|
2019-10-25 16:17:14 +00:00
|
|
|
DEBUG=1 ./$(APPNAME)
|
2019-10-03 19:30:04 +00:00
|
|
|
|
2019-10-25 16:17:14 +00:00
|
|
|
build: ./$(APPNAME)
|
2019-10-03 19:30:04 +00:00
|
|
|
|
2019-10-25 16:17:14 +00:00
|
|
|
./$(APPNAME): *.go
|
2019-10-03 19:30:04 +00:00
|
|
|
go build -o $@ $(GOFLAGS) .
|
|
|
|
|
2019-10-03 19:35:33 +00:00
|
|
|
clean:
|
2019-10-25 16:17:14 +00:00
|
|
|
rm $(APPNAME)
|
2019-10-03 19:35:33 +00:00
|
|
|
|
2019-10-03 19:30:04 +00:00
|
|
|
fmt:
|
|
|
|
go fmt *.go
|
|
|
|
|
2019-10-25 16:17:14 +00:00
|
|
|
test: build-image
|
|
|
|
|
|
|
|
build-and-push-image: push-image
|
|
|
|
|
|
|
|
push-image: build-image
|
|
|
|
docker push sneak/$(APPNAME)
|
|
|
|
|
|
|
|
build-image:
|
|
|
|
docker build \
|
|
|
|
-t sneak/$(APPNAME):$(VERSION) \
|
|
|
|
.
|