From ae1556e503a4cabd64a4949da4ee8f1df0f6b96f Mon Sep 17 00:00:00 2001 From: Endial Fang Date: Mon, 14 Sep 2020 16:06:25 +0800 Subject: [PATCH] =?UTF-8?q?[fix:12]=E8=A7=A3=E5=86=B3Makefile=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E4=B8=AD=E7=89=88=E6=9C=AC=E7=94=9F=E6=88=90=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E9=97=AE=E9=A2=98=EF=BC=9B=E6=9B=B4=E6=96=B0debian?= =?UTF-8?q?=E4=B8=8Ealpine=E9=95=9C=E5=83=8F=E6=A0=87=E7=AD=BE=E5=91=BD?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 3460563..9cbce72 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,8 @@ app_name :=colovu/postgres # <镜像名>:<分支名>- # Git 仓库且无文件修改直接编译 # <镜像名>:<分支名>-<年月日>-<时分秒> # Git 仓库有文件修改后的编译 # <镜像名>:latest-<年月日>-<时分秒> # 非 Git 仓库编译 -current_subversion:=$(shell if [[ -d .git ]]; then git rev-parse --short HEAD; else date +%y%m%d-%H%M%S; fi) -current_tag:=$(shell if [[ -d .git ]]; then git rev-parse --abbrev-ref HEAD | sed -e 's/master/latest/'; else echo "latest"; fi)-$(current_subversion) +current_subversion:=$(shell if [ ! `git status >/dev/null 2>&1` ]; then git rev-parse --short HEAD; else date +%y%m%d-%H%M%S; fi) +current_tag:=$(shell if [ ! `git status >/dev/null 2>&1` ]; then git rev-parse --abbrev-ref HEAD | sed -e 's/master/latest/'; else echo "latest"; fi)-$(current_subversion) # Sources List: default / tencent / ustc / aliyun / huawei build-arg:=--build-arg apt_source=tencent @@ -21,20 +21,20 @@ build-arg+=--build-arg local_url=http://$(local_ip)/dist-files .PHONY: build build-debian build-alpine clean clearclean upgrade -build-debian: - @echo "Build $(app_name):$(current_tag)-deb" - @docker build --force-rm $(build-arg) -t $(app_name):$(current_tag)-deb . - @echo "Add tag: $(app_name):latest-deb" - @docker tag $(app_name):$(current_tag)-deb $(app_name):latest-deb +build: build-alpine build-debian + @echo "Build complete" -build-alpine: +build-debian: @echo "Build $(app_name):$(current_tag)" - @docker build --force-rm $(build-arg) -t $(app_name):$(current_tag) ./alpine + @docker build --force-rm $(build-arg) -t $(app_name):$(current_tag) . @echo "Add tag: $(app_name):latest" @docker tag $(app_name):$(current_tag) $(app_name):latest -build: build-debian build-alpine - @echo "Build complete" +build-alpine: + @echo "Build $(app_name):$(current_tag)-alpine" + @docker build --force-rm $(build-arg) -t $(app_name):$(current_tag)-alpine ./alpine + @echo "Add tag: $(app_name):latest-alpine" + @docker tag $(app_name):$(current_tag)-alpine $(app_name):latest-alpine # 清理悬空的镜像(无TAG)及停止的容器 clearclean: clean