Skip to content

Commit 5e4145b

Browse files
committed
remove go proxy settings
1 parent a5820f9 commit 5e4145b

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,18 @@ FROM ${builder_image} as builder
2929
WORKDIR /workspace
3030

3131
# Run this with docker build --build-arg goproxy=$(go env GOPROXY) to override the goproxy
32-
ARG goproxy=off
33-
# Run this with docker build --build-arg package=./controlplane/kubeadm or --build-arg package=./bootstrap/kubeadm
32+
ARG goproxy=https://proxy.golang.org
3433
ENV GOPROXY=$goproxy
3534

3635
# Copy the Go Modules manifests
3736
COPY go.mod go.mod
3837
COPY go.sum go.sum
3938

39+
# Cache deps before building and copying source so that we don't need to re-download as much
40+
# and so that source changes don't invalidate our downloaded layer
41+
RUN --mount=type=cache,target=/go/pkg/mod \
42+
go mod download
43+
4044
# Copy the sources
4145
COPY ./ ./
4246

@@ -46,7 +50,9 @@ ARG ARCH
4650
ARG ldflags
4751

4852
# Do not force rebuild of up-to-date packages (do not use -a) and use the compiler cache folder
49-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \
53+
RUN --mount=type=cache,target=/root/.cache/go-build \
54+
--mount=type=cache,target=/go/pkg/mod \
55+
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \
5056
go build -trimpath -ldflags "${ldflags} -extldflags '-static'" \
5157
-o manager ${package}
5258

Makefile

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ GO_CONTAINER_IMAGE ?= docker.io/library/golang:$(GO_VERSION)
2525

2626
ARCH ?= $(shell go env GOARCH)
2727

28-
# Use GOPROXY environment variable if set
29-
GOPROXY := $(shell go env GOPROXY)
30-
ifeq ($(GOPROXY),)
31-
GOPROXY := https://proxy.golang.org
32-
endif
33-
export GOPROXY
34-
3528
# Active module mode, as we use go modules to manage dependencies
3629
export GO111MODULE=on
3730

@@ -231,7 +224,7 @@ generate-bootstrap-conversions: $(CONVERSION_GEN)
231224

232225
# Build the docker image
233226
docker-build-bootstrap: manager-bootstrap ## Build bootstrap
234-
DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg goproxy=$(GOPROXY) --build-arg ARCH=$(ARCH) --build-arg package=./bootstrap/main.go --build-arg ldflags="$(LDFLAGS)" . -t ${BOOTSTRAP_IMG}:${BOOTSTRAP_IMG_TAG}
227+
DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg ARCH=$(ARCH) --build-arg package=./bootstrap/main.go --build-arg ldflags="$(LDFLAGS)" . -t ${BOOTSTRAP_IMG}:${BOOTSTRAP_IMG_TAG}
235228

236229
# Push the docker image
237230
docker-push-bootstrap: ## Push bootstrap
@@ -303,7 +296,7 @@ generate-controlplane-conversions: $(CONVERSION_GEN)
303296
--go-header-file=./hack/boilerplate.go.txt
304297

305298
docker-build-controlplane: manager-controlplane ## Build control-plane
306-
DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg goproxy=$(GOPROXY) --build-arg ARCH=$(ARCH) --build-arg package=./controlplane/main.go --build-arg ldflags="$(LDFLAGS)" . -t ${CONTROLPLANE_IMG}:$(CONTROLPLANE_IMG_TAG)
299+
DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg ARCH=$(ARCH) --build-arg package=./controlplane/main.go --build-arg ldflags="$(LDFLAGS)" . -t ${CONTROLPLANE_IMG}:$(CONTROLPLANE_IMG_TAG)
307300

308301
docker-push-controlplane: ## Push control-plane
309302
docker push ${CONTROLPLANE_IMG}:$(CONTROLPLANE_IMG_TAG)

0 commit comments

Comments
 (0)