Skip to content

Commit

Permalink
Merge pull request #871 from smoser/fix/proxy-to-docker
Browse files Browse the repository at this point in the history
build: Pass proxy environment variables through to docker containers.
  • Loading branch information
etungsten authored Mar 26, 2020
2 parents abbb24f + 47d34bf commit 455fd26
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 455fd26

Please sign in to comment.