Skip to content

Commit 0ccf800

Browse files
ahalimx86zshi-redhat
authored andcommitted
allowing proxy-settings to be passed in for Docker
This changes will allow proxy settings to be passed in for docker as well as Env variable in Dockerfile. simply invoke 'make image HTTP_PROXY=http://whateverhost:port'. Change-Id: I4264b2a96d86a6feedee1b21a9f1bac8e74c8fc5
1 parent bad7731 commit 0ccf800

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ FROM centos:centos7
22

33
ADD . /usr/src/sriov-network-device-plugin
44

5+
ENV HTTP_PROXY $http_proxy
6+
ENV HTTPS_PROXY $https_proxy
57
ENV INSTALL_PKGS "git golang make"
68
RUN yum install -y $INSTALL_PKGS && \
79
rpm -V $INSTALL_PKGS && \

Makefile

+10-5
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,19 @@ TESTPKGS = $(shell env GOPATH=$(GOPATH) $(GO) list -f '{{ if or .TestGoFiles .XT
1616

1717
export GOPATH
1818
export GOBIN
19+
1920
# Docker
2021
IMAGEDIR=$(BASE)/images
2122
DOCKERFILE=$(CURDIR)/Dockerfile
2223
TAG=nfvpe/sriov-device-plugin
24+
# Accept proxy settings for docker
25+
DOCKERARGS=
26+
ifdef HTTP_PROXY
27+
DOCKERARGS += --build-arg http_proxy=$(HTTP_PROXY)
28+
endif
29+
ifdef HTTPS_PROXY
30+
DOCKERARGS += --build-arg https_proxy=$(HTTPS_PROXY)
31+
endif
2332

2433
# Go tools
2534
GO = go
@@ -137,11 +146,7 @@ vendor: glide.lock | $(BASE) ; $(info retrieving dependencies...)
137146
# To pass proxy for Docker invoke it as 'make image HTTP_POXY=http://192.168.0.1:8080'
138147
.PHONY: image
139148
image: | $(BASE) ; $(info Building Docker image...)
140-
ifdef HTTP_PROXY
141-
@docker build -t $(TAG) -f $(DOCKERFILE) $(CURDIR) --build-arg http_proxy=$(HTTP_PROXY)
142-
else
143-
@docker build -t $(TAG) -f $(DOCKERFILE) $(CURDIR)
144-
endif
149+
@docker build -t $(TAG) -f $(DOCKERFILE) $(CURDIR) $(DOCKERARGS)
145150

146151
# Misc
147152

0 commit comments

Comments
 (0)