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) APPNAME := merp GOLDFLAGS += -X main.Version=$(VERSION) GOLDFLAGS += -X main.Buildtime=$(BUILDTIME) GOLDFLAGS += -X main.Builduser=$(BUILDUSER)@$(BUILDHOST) GOLDFLAGS += -X main.Buildarch=$(BUILDARCH) GOLDFLAGS += -X main.Appname=$(APPNAME) GOFLAGS = -ldflags "$(GOLDFLAGS)" default: run run: build DEBUG=1 ./$(APPNAME) build: ./$(APPNAME) ./$(APPNAME): *.go go build -o $@ $(GOFLAGS) . clean: rm $(APPNAME) fmt: go fmt *.go 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) \ .