Skip to content

Commit

Permalink
Change build commands to use vendoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
jkh52 committed Jan 26, 2024
1 parent 698bc48 commit 02ed8d9
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 38 deletions.
28 changes: 15 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,36 +57,38 @@ mock_gen:

.PHONY: test
test:
go test -race -covermode=atomic -coverprofile=konnectivity.out ./... && go tool cover -html=konnectivity.out -o=konnectivity.html
cd konnectivity-client && go test -race -covermode=atomic -coverprofile=client.out ./... && go tool cover -html=client.out -o=client.html
go test -mod=vendor -race -covermode=atomic -coverprofile=konnectivity.out ./... && go tool cover -html=konnectivity.out -o=konnectivity.html
cd konnectivity-client && go test -mod=vendor -race -covermode=atomic -coverprofile=client.out ./... && go tool cover -html=client.out -o=client.html

.PHONY: test-integration
test-integration: build
go test -race ./tests -agent-path $(PWD)/bin/proxy-agent
go test -mod=vendor -race ./tests -agent-path $(PWD)/bin/proxy-agent

## --------------------------------------
## Binaries
## --------------------------------------

SOURCE = $(shell find . -name \*.go)

bin:
mkdir -p bin

.PHONY: build
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
.PHONY: bin/proxy-agent
bin/proxy-agent:
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
.PHONY: bin/proxy-test-client
bin/proxy-test-client:
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
.PHONY: bin/http-test-server
bin/http-test-server:
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
.PHONY: bin/proxy-server
bin/proxy-server:
GO111MODULE=on go build -mod=vendor -o bin/proxy-server cmd/server/main.go

## --------------------------------------
## Linting
Expand Down
11 changes: 5 additions & 6 deletions artifacts/images/agent-build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions artifacts/images/server-build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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
Expand Down
10 changes: 4 additions & 6 deletions artifacts/images/test-client-build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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
Expand Down
11 changes: 4 additions & 7 deletions artifacts/images/test-server-build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@ 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/

# 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
Expand Down

0 comments on commit 02ed8d9

Please sign in to comment.