From 17973c5d7d3021dbc1f1214580e916b0f66a9c6f Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Fri, 8 Jun 2018 09:17:21 -0500 Subject: [PATCH] Docker: support build behind proxy This PS adds support to build behind a corp proxy. Change-Id: I435065e99113f2319101b6cd2924edc4a94b03be Signed-off-by: Pete Birley --- Makefile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a0d82d79..a6657337 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,9 @@ IMAGE_NAME ?= deckhand IMAGE_PREFIX ?= attcomdev IMAGE_TAG ?= latest HELM ?= helm +PROXY ?= http://proxy.foo.com:8000 +USE_PROXY ?= false +PUSH_IMAGE ?= false LABEL ?= commit-id IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG} @@ -48,7 +51,14 @@ tests: # Make targets intended for use by the primary targets above. .PHONY: build_deckhand build_deckhand: - docker build -t $(IMAGE) --label $(LABEL) -f images/deckhand/Dockerfile . +ifeq ($(USE_PROXY), true) + docker build --network host -t $(IMAGE) --label $(LABEL) -f images/deckhand/Dockerfile . --build-arg http_proxy=$(PROXY) --build-arg https_proxy=$(PROXY) +else + docker build --network host -t $(IMAGE) --label $(LABEL) -f images/deckhand/Dockerfile . +endif +ifeq ($(PUSH_IMAGE), true) + docker push $(IMAGE) +endif .PHONY: clean clean: