From e873bbb2810ed02d71d39bf42d83d8dadabc7ea2 Mon Sep 17 00:00:00 2001 From: Stanislav Egorov Date: Tue, 12 May 2020 23:58:13 -0700 Subject: [PATCH] Fixed docker build space issue By default docker build doesn't remove intermediate containers when build is failed. They are accumulated and we can see disk space issue. Enabled force mode to remove intermediate containers even if build is failed. It can be overriden for debugging purposes via env vars for make. Example: DOCKER_FORCE_CLEAN=false make docker-image Change-Id: Ia68916b78fc91704e296ebe1ae05d1168a17fdc2 --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 17e0814db..463934d46 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ DOCKER_MAKE_TARGET := build # docker image options DOCKER_REGISTRY ?= quay.io +DOCKER_FORCE_CLEAN ?= true DOCKER_IMAGE_NAME ?= airshipctl DOCKER_IMAGE_PREFIX ?= airshipit DOCKER_IMAGE_TAG ?= dev @@ -108,12 +109,14 @@ ifeq ($(USE_PROXY), true) --build-arg NO_PROXY=$(NO_PROXY) \ --build-arg MAKE_TARGET=$(DOCKER_MAKE_TARGET) \ --tag $(DOCKER_IMAGE) \ - --target $(DOCKER_TARGET_STAGE) + --target $(DOCKER_TARGET_STAGE) \ + --force-rm=$(DOCKER_FORCE_CLEAN) else @docker build . --network=host \ --build-arg MAKE_TARGET=$(DOCKER_MAKE_TARGET) \ --tag $(DOCKER_IMAGE) \ - --target $(DOCKER_TARGET_STAGE) + --target $(DOCKER_TARGET_STAGE) \ + --force-rm=$(DOCKER_FORCE_CLEAN) endif ifeq ($(PUBLISH), true) @docker push $(DOCKER_IMAGE)