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

@ -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)