From d9417b47a5440a1f7f7b7bf07b0e10f5b1783e15 Mon Sep 17 00:00:00 2001 From: ehlxr Date: Fri, 15 Nov 2019 11:30:18 +0800 Subject: [PATCH] init --- Makefile | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b428005..e7e7958 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,14 @@ LD_GO_VERSION := -X '$(VERSION_PATH).GoVersion=`go version`' LD_VERSION := -X '$(VERSION_PATH).Version=$(BUILD_VERSION)' LD_FLAGS := "$(LD_APP_NAMW) $(LD_GIT_COMMIT) $(LD_BUILD_TIME) $(LD_GO_VERSION) $(LD_VERSION) -w -s" -.PHONY : build release clean install upx +RELEASE_VERSION = $(version) +REGISTRY_URL = $(url) + +ifeq ("$(RELEASE_VERSION)","") + RELEASE_VERSION := $(shell echo `date "+%Y%m%d_%H%M%S"`) +endif + +.PHONY : build release clean install upx docker-push docker build: ifneq ($(shell type gox >/dev/null 2>&1;echo $$?), 0) @@ -24,6 +31,18 @@ endif gox -ldflags $(LD_FLAGS) -osarch="darwin/amd64 linux/386 linux/amd64 windows/amd64" \ -output="$(DIST_DIR){{.Dir}}_{{.OS}}_{{.Arch}}" +docker: build upx +ifneq ("$(REGISTRY_URL)","") + @echo ========== current docker tag is: $(RELEASE_VERSION) ========== + + docker build -t $(REGISTRY_URL)/ddgo_server:$(RELEASE_VERSION) -f Dockerfile . +else + @echo "url arg should not be empty" +endif + +docker-push: docker + docker push $(REGISTRY_URL)/ddgo_server:$(RELEASE_VERSION) + clean: rm -rf $(DIST_DIR)*