Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass environment variables to go build command of build_gcsfuse to support builds behind an HTTP proxy #1899

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

OutSorcerer
Copy link

@OutSorcerer OutSorcerer commented May 9, 2024

Description

The problem I faced is described in the title, I hope this fix can be useful to someone else too.

I have a custom Dockerfile based on the original Dockerfile in this repo, and my build runs behind an HTTP proxy, the build was failing. I realized it was due the following code snippet in tools/build_gcsfuse/main.go:

cmd := exec.Command(
	"go",
	"build",
	...
			
// Set up environment.
cmd.Env = []string{
	"GO15VENDOREXPERIMENT=1",
	"GO111MODULE=auto",
	fmt.Sprintf("PATH=%s", pathEnv),
	fmt.Sprintf("GOROOT=%s", runtime.GOROOT()),
	fmt.Sprintf("GOPATH=%s", gopath),
	fmt.Sprintf("GOCACHE=%s", gocache),
	"CGO_ENABLED=0",
}			

This code ignores all the current environment variables, which is IMHO unexpected as it runs inside Docker which already takes care about creating an isolated environment with fresh values of environment variables.

The particular variable important for my case was https_proxy, without it go build was failing as it was unable to access internet directly.

That variable was passed with ~/.docker/config.json like described in Docker docs.

Link to the issue in case of a bug fix.

NA

Testing details

  1. Manual - NA
  2. Unit tests - NA
  3. Integration tests - NA

@OutSorcerer OutSorcerer requested a review from a team as a code owner May 9, 2024 17:44
Copy link

google-cla bot commented May 9, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant