Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Configure GOPROXY #606

Merged
merged 1 commit into from Sep 13, 2019
Merged

Configure GOPROXY #606

merged 1 commit into from Sep 13, 2019

Conversation

ndeloof
Copy link
Contributor

@ndeloof ndeloof commented Sep 3, 2019

- What I did
introduce support for GOPROXY

- How I did it
pass --build-arg according to local value.
set GOPROXY to direct for CI

- How to verify it
No obvious way

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@codecov
Copy link

codecov bot commented Sep 3, 2019

Codecov Report

Merging #606 into master will decrease coverage by 0.28%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #606      +/-   ##
=========================================
- Coverage   72.69%   72.4%   -0.29%     
=========================================
  Files          54      54              
  Lines        2809    2765      -44     
=========================================
- Hits         2042    2002      -40     
+ Misses        508     506       -2     
+ Partials      259     257       -2
Impacted Files Coverage Δ
render/render.go 76.38% <0%> (-5.51%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 964210e...5234af7. Read the comment docs.

@ndeloof ndeloof force-pushed the goproxy branch 2 times, most recently from 872413a to f6e35d2 Compare September 3, 2019 12:33
Dockerfile Outdated
@@ -10,6 +10,7 @@ WORKDIR /go/src/github.com/docker/cli

RUN git clone https://github.com/docker/cli . && git checkout a1b83ffd2cbeefc0752e5aa7a543d49c1ddfd2cb

ARG GOPROXY=direct
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Significant issue I see here is that this forces a value to GOPROXY, not just let us override the default one on purpose. Any suggestions for adequate docker build hack is welcome :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as for the command-line argument, you can omit the value (and =);

1. no --build-arg

docker build -<<'EOF'
FROM busybox
ARG GOPROXY
RUN env && exit 1
EOF

 > [2/2] RUN env && exit 1:
#5 0.563 SHLVL=1
#5 0.563 HOME=/root
#5 0.563 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#5 0.563 PWD=/

2. with --build-arg=GOPROXY, but no env-var set

docker build --build-arg=GOPROXY -<<'EOF'
FROM busybox
ARG GOPROXY
RUN env && exit 1
EOF

 > [2/2] RUN env && exit 1:
#4 0.329 SHLVL=1
#4 0.329 HOME=/root
#4 0.329 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#4 0.329 PWD=/

3. with --build-arg=GOPROXY and $GOPROXY set as env-var

GOPROXY=direct docker build --build-arg=GOPROXY -<<'EOF'
FROM busybox
ARG GOPROXY
RUN env && exit 1
EOF

 > [2/2] RUN env && exit 1:                                                                                                                                                                                                                      
#5 0.376 SHLVL=1                                                                                                                                                                                                                                 
#5 0.376 HOME=/root                                                                                                                                                                                                                              
#5 0.376 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin                                                                                                                                                                       
#5 0.376 GOPROXY=direct
#5 0.376 PWD=/

4. with value passed as --build-arg=GOPROXY=foobar

docker build --build-arg=GOPROXY=foobar -<<'EOF'
FROM busybox
ARG GOPROXY
RUN env && exit 1
EOF

 > [2/2] RUN env && exit 1:                                                                                                                                                                                                                      
#5 0.327 SHLVL=1                                                                                                                                                                                                                                 
#5 0.327 HOME=/root                                                                                                                                                                                                                              
#5 0.327 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin                                                                                                                                                                       
#5 0.327 GOPROXY=foobar
#5 0.327 PWD=/

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndeloof - left some suggestions

docker.Makefile Outdated
@@ -17,6 +17,10 @@ SCHEMAS_CTNR_NAME := $(BIN_NAME)-schemas-$(TAG)

BUILD_ARGS=--build-arg=EXPERIMENTAL=$(EXPERIMENTAL) --build-arg=TAG=$(TAG) --build-arg=COMMIT=$(COMMIT) --build-arg=ALPINE_VERSION=$(ALPINE_VERSION)

ifneq ($(GOPROXY),)
BUILD_ARGS = $(BUILD_ARGS) --build-arg=GOPROXY=$(GOPROXY)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it helps, but omitting the value (and the =, because that implicitly is equal to ="") will take the value from the current environment, so if GOPROXY is not set as an environment variable, it won't be passed as a build-arg

--build-arg=GOPROXY

Dockerfile Outdated
@@ -10,6 +10,7 @@ WORKDIR /go/src/github.com/docker/cli

RUN git clone https://github.com/docker/cli . && git checkout a1b83ffd2cbeefc0752e5aa7a543d49c1ddfd2cb

ARG GOPROXY=direct
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as for the command-line argument, you can omit the value (and =);

1. no --build-arg

docker build -<<'EOF'
FROM busybox
ARG GOPROXY
RUN env && exit 1
EOF

 > [2/2] RUN env && exit 1:
#5 0.563 SHLVL=1
#5 0.563 HOME=/root
#5 0.563 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#5 0.563 PWD=/

2. with --build-arg=GOPROXY, but no env-var set

docker build --build-arg=GOPROXY -<<'EOF'
FROM busybox
ARG GOPROXY
RUN env && exit 1
EOF

 > [2/2] RUN env && exit 1:
#4 0.329 SHLVL=1
#4 0.329 HOME=/root
#4 0.329 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#4 0.329 PWD=/

3. with --build-arg=GOPROXY and $GOPROXY set as env-var

GOPROXY=direct docker build --build-arg=GOPROXY -<<'EOF'
FROM busybox
ARG GOPROXY
RUN env && exit 1
EOF

 > [2/2] RUN env && exit 1:                                                                                                                                                                                                                      
#5 0.376 SHLVL=1                                                                                                                                                                                                                                 
#5 0.376 HOME=/root                                                                                                                                                                                                                              
#5 0.376 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin                                                                                                                                                                       
#5 0.376 GOPROXY=direct
#5 0.376 PWD=/

4. with value passed as --build-arg=GOPROXY=foobar

docker build --build-arg=GOPROXY=foobar -<<'EOF'
FROM busybox
ARG GOPROXY
RUN env && exit 1
EOF

 > [2/2] RUN env && exit 1:                                                                                                                                                                                                                      
#5 0.327 SHLVL=1                                                                                                                                                                                                                                 
#5 0.327 HOME=/root                                                                                                                                                                                                                              
#5 0.327 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin                                                                                                                                                                       
#5 0.327 GOPROXY=foobar
#5 0.327 PWD=/

@ndeloof
Copy link
Contributor Author

ndeloof commented Sep 3, 2019

@thaJeztah great suggestion, I didn't know about the --build-arg=FOO trick, you made my day ;)

@thaJeztah
Copy link
Member

Works the same for --env btw, and it's a great way to optionally pass an env-var to a container 😅

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@chris-crone chris-crone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chris-crone chris-crone merged commit ab21570 into docker:master Sep 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants