Skip to content

Commit 7998955

Browse files
authored
feat: add support for image building with a custom GOPROXY and builder (Mellanox#1683)
2 parents 44c7b05 + d0efb94 commit 7998955

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616

1717
jobs:
1818
docker-build-push:
19-
runs-on: ubuntu-24.04
19+
runs-on: linux-amd64-cpu4
2020
steps:
2121
- uses: actions/checkout@v4
2222
- name: Determine docker tags
@@ -33,6 +33,7 @@ jobs:
3333
- name: Make build and push
3434
env:
3535
TAG: mellanox/${{ env.IMAGE_NAME }}
36+
GOPROXY: ${{ secrets.GOPROXY }}
3637
run: |
3738
echo "Docker tags will be: $DOCKER_TAGS"
3839
for docker_tag in $DOCKER_TAGS; do

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ COPY ./ ./
3535
ARG ARCH
3636
ARG LDFLAGS
3737
ARG GCFLAGS
38+
ARG GOPROXY=direct
39+
ENV GOPROXY=$GOPROXY
40+
3841
RUN --mount=type=cache,target=/go/pkg/mod \
3942
--mount=type=cache,target=/root/.cache/go-build \
4043
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -ldflags="${LDFLAGS}" -gcflags="${GCFLAGS}" -o manager main.go && \

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ TESTPKGS=./...
2727
ENVTEST_K8S_VERSION=1.28
2828
ARCH ?= $(shell go env GOARCH)
2929
OS ?= $(shell go env GOOS)
30+
GOPROXY ?= direct
3031

3132
# Version
3233
VERSION?=master
@@ -299,6 +300,7 @@ image: ; $(info Building Docker image...) @ ## Build container image
299300
--build-arg LDFLAGS=$(LDFLAGS) \
300301
--build-arg ARCH="$(ARCH)" \
301302
--build-arg GCFLAGS="$(GCFLAGS)" \
303+
--build-arg GOPROXY="$(GOPROXY)" \
302304
-t $(TAG) -f $(DOCKERFILE) $(CURDIR) $(IMAGE_BUILD_OPTS)
303305

304306
image-push:
@@ -318,6 +320,7 @@ image-build: ; $(info Building Docker image...) @ ## Build container image
318320
--build-arg LDFLAGS=$(LDFLAGS) \
319321
--build-arg ARCH="$(ARCH)" \
320322
--build-arg GCFLAGS="$(GCFLAGS)" \
323+
--build-arg GOPROXY="$(GOPROXY)" \
321324
-t $(CONTROLLER_IMAGE):$(VERSION)-$(ARCH) -f $(DOCKERFILE) $(CURDIR) $(IMAGE_BUILD_OPTS)
322325

323326
image-build-%:

0 commit comments

Comments
 (0)