From 47d34bfbbe1aa6b91565ca00ad0e1425822ceb90 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Thu, 26 Mar 2020 12:39:00 -0400 Subject: [PATCH] build: Pass proxy environment variables through to docker containers. When building behind a proxy, build via 'cargo make' worked up to the point of 'running Task: fetch-vendored' where it hung. The reason was because necessary proxy environment variables were not passed into the docker container's environment. The fix here is to add these variables to the environment of the docker container if they are set outside the container: http_proxy, https_proxy, no_proxy --- tools/docker-go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/docker-go b/tools/docker-go index 548386e48d7..bae49199a10 100755 --- a/tools/docker-go +++ b/tools/docker-go @@ -54,10 +54,19 @@ DOCKER_RUN_ARGS="--network=host" parse_args "${@}" +# Go accepts both lower and uppercase proxy variables, pass both through. +proxy_env=( ) +for i in http_proxy https_proxy no_proxy HTTP_PROXY HTTPS_PROXY NO_PROXY; do + if [ -n "${!i}" ]; then + proxy_env[${#proxy_env[@]}]="--env=$i=${!i}" + fi +done + docker run --rm \ -e GOPRIVATE='*' \ -e GOCACHE='/tmp/.cache' \ -e GOPATH='/tmp/go' \ + "${proxy_env[@]}" \ --user "$(id -u):$(id -g)" \ ${DOCKER_RUN_ARGS} \ -v "${GO_MOD_CACHE}":/tmp/go/pkg/mod \