| 1 |
# Build the proxy-server binary |
| 2 |
|
| 3 |
ARG BUILDARCH |
| 4 |
ARG GO_TOOLCHAIN |
| 5 |
ARG GO_VERSION |
| 6 |
ARG BASEIMAGE |
| 7 |
|
| 8 |
FROM --platform=linux/${BUILDARCH} ${GO_TOOLCHAIN}:${GO_VERSION} AS builder |
| 9 |
|
| 10 |
# Copy in the go src |
| 11 |
WORKDIR /go/src/sigs.k8s.io/apiserver-network-proxy |
| 12 |
|
| 13 |
# Copy the Go Modules manifests |
| 14 |
COPY go.mod go.mod |
| 15 |
COPY go.sum go.sum |
| 16 |
|
| 17 |
# We have a replace directive for konnectivity-client in go.mod |
| 18 |
COPY konnectivity-client/ konnectivity-client/ |
| 19 |
|
| 20 |
# Copy vendored modules |
| 21 |
COPY vendor/ vendor/ |
| 22 |
|
| 23 |
# Copy the sources |
| 24 |
COPY pkg/ pkg/ |
| 25 |
COPY cmd/ cmd/ |
| 26 |
COPY proto/ proto/ |
| 27 |
|
| 28 |
# Build |
| 29 |
ARG TARGETARCH |
| 30 |
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -mod=vendor -v -a -ldflags '-extldflags "-static"' -o proxy-server sigs.k8s.io/apiserver-network-proxy/cmd/server |
| 31 |
|
| 32 |
FROM ${BASEIMAGE} |
| 33 |
|
| 34 |
WORKDIR / |
| 35 |
COPY --from=builder /go/src/sigs.k8s.io/apiserver-network-proxy/proxy-server . |
| 36 |
ENTRYPOINT ["/proxy-server"] |