From 17716744ef0e53d66708a4d9d0afada8f717e01e Mon Sep 17 00:00:00 2001 From: Joseph Anttila Hall Date: Tue, 23 Jan 2024 16:45:49 -0800 Subject: [PATCH] Change build commands to use vendoring. --- Makefile | 8 ++++---- artifacts/images/agent-build.Dockerfile | 11 +++++------ artifacts/images/server-build.Dockerfile | 10 ++++------ artifacts/images/test-client-build.Dockerfile | 10 ++++------ artifacts/images/test-server-build.Dockerfile | 11 ++++------- 5 files changed, 21 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index aa23c9990..e2dec8ed2 100644 --- a/Makefile +++ b/Makefile @@ -77,16 +77,16 @@ bin: build: bin/proxy-agent bin/proxy-server bin/proxy-test-client bin/http-test-server bin/proxy-agent: bin $(SOURCE) - GO111MODULE=on go build -o bin/proxy-agent cmd/agent/main.go + GO111MODULE=on go build -mod=vendor -o bin/proxy-agent cmd/agent/main.go bin/proxy-test-client: bin $(SOURCE) - GO111MODULE=on go build -o bin/proxy-test-client cmd/test-client/main.go + GO111MODULE=on go build -mod=vendor -o bin/proxy-test-client cmd/test-client/main.go bin/http-test-server: bin $(SOURCE) - GO111MODULE=on go build -o bin/http-test-server cmd/test-server/main.go + GO111MODULE=on go build -mod=vendor -o bin/http-test-server cmd/test-server/main.go bin/proxy-server: bin $(SOURCE) - GO111MODULE=on go build -o bin/proxy-server cmd/server/main.go + GO111MODULE=on go build -mod=vendor -o bin/proxy-server cmd/server/main.go ## -------------------------------------- ## Linting diff --git a/artifacts/images/agent-build.Dockerfile b/artifacts/images/agent-build.Dockerfile index 57eeb4308..c54c52abc 100644 --- a/artifacts/images/agent-build.Dockerfile +++ b/artifacts/images/agent-build.Dockerfile @@ -8,22 +8,21 @@ WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy COPY go.mod go.mod COPY go.sum go.sum -# This is required before go mod download because we have a -# replace directive for konnectivity-client in go.mod -# The download will fail without the directory present +# We have a replace directive for konnectivity-client in go.mod COPY konnectivity-client/ konnectivity-client/ -# Cache dependencies -RUN go mod download +# Copy vendored modules +COPY vendor/ vendor/ # Copy the sources COPY pkg/ pkg/ COPY cmd/ cmd/ COPY proto/ proto/ + # Build ARG ARCH -RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -v -a -ldflags '-extldflags "-static"' -o proxy-agent sigs.k8s.io/apiserver-network-proxy/cmd/agent +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -mod=vendor -v -a -ldflags '-extldflags "-static"' -o proxy-agent sigs.k8s.io/apiserver-network-proxy/cmd/agent # Copy the loader into a thin image FROM gcr.io/distroless/static-debian11 diff --git a/artifacts/images/server-build.Dockerfile b/artifacts/images/server-build.Dockerfile index f7f49dcea..5587faad0 100644 --- a/artifacts/images/server-build.Dockerfile +++ b/artifacts/images/server-build.Dockerfile @@ -8,13 +8,11 @@ WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy COPY go.mod go.mod COPY go.sum go.sum -# This is required before go mod download because we have a -# replace directive for konnectivity-client in go.mod -# The download will fail without the directory present +# We have a replace directive for konnectivity-client in go.mod COPY konnectivity-client/ konnectivity-client/ -# Cache dependencies -RUN go mod download +# Copy vendored modules +COPY vendor/ vendor/ # Copy the sources COPY pkg/ pkg/ @@ -23,7 +21,7 @@ COPY proto/ proto/ # Build ARG ARCH -RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -v -a -ldflags '-extldflags "-static"' -o proxy-server sigs.k8s.io/apiserver-network-proxy/cmd/server +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -mod=vendor -v -a -ldflags '-extldflags "-static"' -o proxy-server sigs.k8s.io/apiserver-network-proxy/cmd/server # Copy the loader into a thin image FROM gcr.io/distroless/static-debian11 diff --git a/artifacts/images/test-client-build.Dockerfile b/artifacts/images/test-client-build.Dockerfile index 71f44a4a8..b24e11e68 100644 --- a/artifacts/images/test-client-build.Dockerfile +++ b/artifacts/images/test-client-build.Dockerfile @@ -8,13 +8,11 @@ WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy COPY go.mod go.mod COPY go.sum go.sum -# This is required before go mod download because we have a -# replace directive for konnectivity-client in go.mod -# The download will fail without the directory present +# We have a replace directive for konnectivity-client in go.mod COPY konnectivity-client/ konnectivity-client/ -# Cache dependencies -RUN go mod download +# Copy vendored modules +COPY vendor/ vendor/ # Copy the sources COPY pkg/ pkg/ @@ -23,7 +21,7 @@ COPY proto/ proto/ # Build ARG ARCH -RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -v -a -ldflags '-extldflags "-static"' -o proxy-test-client sigs.k8s.io/apiserver-network-proxy/cmd/test-client +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -mod=vendor -v -a -ldflags '-extldflags "-static"' -o proxy-test-client sigs.k8s.io/apiserver-network-proxy/cmd/test-client # Copy the loader into a thin image FROM gcr.io/distroless/static-debian11 diff --git a/artifacts/images/test-server-build.Dockerfile b/artifacts/images/test-server-build.Dockerfile index 3c55310ea..feb837d3d 100644 --- a/artifacts/images/test-server-build.Dockerfile +++ b/artifacts/images/test-server-build.Dockerfile @@ -8,14 +8,11 @@ WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy COPY go.mod go.mod COPY go.sum go.sum - -# This is required before go mod download because we have a -# replace directive for konnectivity-client in go.mod -# The download will fail without the directory present +# We have a replace directive for konnectivity-client in go.mod COPY konnectivity-client/ konnectivity-client/ -# Cache dependencies -RUN go mod download +# Copy vendored modules +COPY vendor/ vendor/ # Copy the sources COPY pkg/ pkg/ @@ -23,7 +20,7 @@ COPY cmd/ cmd/ # Build ARG ARCH -RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -v -a -ldflags '-extldflags "-static"' -o http-test-server sigs.k8s.io/apiserver-network-proxy/cmd/test-server +RUN CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -mod=vendor -v -a -ldflags '-extldflags "-static"' -o http-test-server sigs.k8s.io/apiserver-network-proxy/cmd/test-server # Copy the loader into a thin image FROM gcr.io/distroless/static-debian11