Skip to content

Commit

Permalink
build: Pass proxy environment variables through to docker containers.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
smoser committed Mar 26, 2020
1 parent 2373814 commit 47d34bf
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/docker-go
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 47d34bf

Please sign in to comment.