mark/Makefile
Nick Klauer f437e47039
Add Go Module Support (#18)
* feat: 🔧 add module support

* fix: 🔧 more go module stuff
2020-03-06 13:43:53 +03:00

43 lines
905 B
Makefile

NAME = $(notdir $(PWD))
VERSION = $(shell printf "%s.%s" \
$$(git rev-list --count HEAD) \
$$(git rev-parse --short HEAD) \
)
GO111MODULE = on
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
REMOTE = kovetskiy
version:
@echo $(VERSION)
get:
go get -v -d
build:
@echo :: building go binary $(VERSION)
CGO_ENABLED=0 go build \
-ldflags "-X main.version=$(VERSION)" \
-gcflags "-trimpath $(GOPATH)/src"
image:
@echo :: building image $(NAME):$(VERSION)
@docker build -t $(NAME):$(VERSION) -f Dockerfile .
docker tag $(NAME):$(VERSION) $(NAME):latest
push:
$(if $(REMOTE),,$(error REMOTE is not set))
$(eval VERSION ?= latest)
$(eval TAG ?= $(REMOTE)/$(NAME):$(VERSION))
@echo :: pushing image $(TAG)
@docker tag $(NAME):$(VERSION) $(TAG)
@docker push $(TAG)
@docker tag $(NAME):$(VERSION) $(REMOTE)/$(NAME):latest
@docker push $(REMOTE)/$(NAME):latest
clean:
rm -rf $(NAME)