From babcc79603dacdb7ace26c8b0180fc82aed0a0d5 Mon Sep 17 00:00:00 2001 From: Bassam Tabbara Date: Thu, 30 Mar 2017 17:10:42 +0200 Subject: [PATCH] build: cleanup docker images after publish --- Makefile | 7 +++++++ build/makelib/release.mk | 7 +++++++ build/release/binaries.sh | 4 ++++ build/release/containers.sh | 9 +++++++++ build/release/release.sh | 2 +- 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c921b914b..c53219628 100644 --- a/Makefile +++ b/Makefile @@ -236,6 +236,13 @@ else @echo skipping publish. invalid channel "$(CHANNEL)" endif +publish.cleanup: +ifneq ($(filter master alpha beta stable, $(CHANNEL)),) + @$(MAKE) release.cleanup +else + @echo skipping publish.cleanup. invalid channel "$(CHANNEL)" +endif + .PHONY: build.common cross.build cross.parallel .PHONY: dev build install test check vet fmt vendor clean distclean cross release publish diff --git a/build/makelib/release.mk b/build/makelib/release.mk index a85d89101..53106a91c 100644 --- a/build/makelib/release.mk +++ b/build/makelib/release.mk @@ -76,6 +76,11 @@ release.publish.$(1).$(2): @build/release/release.sh publish $(2) $(1) release.publish.all: release.publish.$(1).$(2) + +release.cleanup.$(1).$(2): + @build/release/release.sh cleanup $(2) $(1) + +release.cleanup.all: release.cleanup.$(1).$(2) endef $(foreach f,$(RELEASE_FLAVORS),$(foreach p,$(RELEASE_PLATFORMS), $(eval $(call release-target,$(f),$(p))))) @@ -83,3 +88,5 @@ $(foreach f,$(RELEASE_FLAVORS),$(foreach p,$(RELEASE_PLATFORMS), $(eval $(call r release.build: release.build.all release.publish: release.publish.all + +release.cleanup: release.cleanup.all diff --git a/build/release/binaries.sh b/build/release/binaries.sh index cce543965..dad51e161 100755 --- a/build/release/binaries.sh +++ b/build/release/binaries.sh @@ -62,6 +62,10 @@ EOF s3_upload $tmpdir/version } +cleanup() { + : +} + action=$1 shift diff --git a/build/release/containers.sh b/build/release/containers.sh index 002e42d21..8bd3a9dee 100755 --- a/build/release/containers.sh +++ b/build/release/containers.sh @@ -65,6 +65,15 @@ publish() { publish_artifact $os $arch rook/rookd } +cleanup() { + local os=$1 + local arch=$2 + + [[ ${os} == "linux" ]] || return 0 + + docker rmi ${registry}${tag} || true +} + publish_artifact() { local os=$1 local arch=$2 diff --git a/build/release/release.sh b/build/release/release.sh index 00ec465d0..2c8d7e22e 100755 --- a/build/release/release.sh +++ b/build/release/release.sh @@ -9,7 +9,7 @@ shift mkdir -p ${RELEASE_DIR} case ${action} in - build|publish) + build|publish|cleanup) platform=$1 shift