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
This commit is contained in:
Stanislav Egorov 2020-05-12 23:58:13 -07:00
parent fc0b53d2b3
commit e873bbb281

View File

@ -19,6 +19,7 @@ DOCKER_MAKE_TARGET := build
# docker image options # docker image options
DOCKER_REGISTRY ?= quay.io DOCKER_REGISTRY ?= quay.io
DOCKER_FORCE_CLEAN ?= true
DOCKER_IMAGE_NAME ?= airshipctl DOCKER_IMAGE_NAME ?= airshipctl
DOCKER_IMAGE_PREFIX ?= airshipit DOCKER_IMAGE_PREFIX ?= airshipit
DOCKER_IMAGE_TAG ?= dev DOCKER_IMAGE_TAG ?= dev
@ -108,12 +109,14 @@ ifeq ($(USE_PROXY), true)
--build-arg NO_PROXY=$(NO_PROXY) \ --build-arg NO_PROXY=$(NO_PROXY) \
--build-arg MAKE_TARGET=$(DOCKER_MAKE_TARGET) \ --build-arg MAKE_TARGET=$(DOCKER_MAKE_TARGET) \
--tag $(DOCKER_IMAGE) \ --tag $(DOCKER_IMAGE) \
--target $(DOCKER_TARGET_STAGE) --target $(DOCKER_TARGET_STAGE) \
--force-rm=$(DOCKER_FORCE_CLEAN)
else else
@docker build . --network=host \ @docker build . --network=host \
--build-arg MAKE_TARGET=$(DOCKER_MAKE_TARGET) \ --build-arg MAKE_TARGET=$(DOCKER_MAKE_TARGET) \
--tag $(DOCKER_IMAGE) \ --tag $(DOCKER_IMAGE) \
--target $(DOCKER_TARGET_STAGE) --target $(DOCKER_TARGET_STAGE) \
--force-rm=$(DOCKER_FORCE_CLEAN)
endif endif
ifeq ($(PUBLISH), true) ifeq ($(PUBLISH), true)
@docker push $(DOCKER_IMAGE) @docker push $(DOCKER_IMAGE)