From 4c3021fa523f9bd08a21ee3d0d0f002f8ca7b0bd Mon Sep 17 00:00:00 2001 From: Michael Glaser Date: Thu, 19 Jul 2018 11:47:17 -0500 Subject: [PATCH] Add conditional proxy values to Makefile Need proxy values when image being built behind a firewall. Change-Id: Ib0be7db3c6508cc69ca8db313b84d9cf2d56b0a4 --- Makefile | 16 +++++++++++++++- tox.ini | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2234e4fd..43190edb 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,9 @@ IMAGE_PREFIX ?= attcomdev IMAGE_TAG ?= ocata HELM ?= helm LABEL ?= commit-id +PROXY ?= http://proxy.foo.com:8000 +NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local +USE_PROXY ?= false IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG} @@ -43,7 +46,18 @@ dry-run: clean # Make targets intended for use by the primary targets above. .PHONY: build_$(IMAGE_NAME) build_$(IMAGE_NAME): - docker build -t $(IMAGE) --label $(LABEL) -f Dockerfile . + +ifeq ($(USE_PROXY), true) + docker build --network host -t $(IMAGE) --label $(LABEL) -f Dockerfile \ + --build-arg http_proxy=$(PROXY) \ + --build-arg https_proxy=$(PROXY) \ + --build-arg HTTP_PROXY=$(PROXY) \ + --build-arg HTTPS_PROXY=$(PROXY) \ + --build-arg no_proxy=$(NO_PROXY) \ + --build-arg NO_PROXY=$(NO_PROXY) . +else + docker build --network host -t $(IMAGE) --label $(LABEL) -f Dockerfile . +endif .PHONY: clean clean: diff --git a/tox.ini b/tox.ini index e18a1fe0..217801fa 100644 --- a/tox.ini +++ b/tox.ini @@ -5,6 +5,7 @@ skipsdist = True [testenv] usedevelop = True +passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages} setenv = VIRTUAL_ENV={envdir}