1515# limitations under the License.
1616
1717# Build the manager binary
18- FROM golang:1.19.8 as toolchain
18+ FROM golang:1.19.10-alpine3.18 as toolchain
1919
2020# Run this with docker build --build_arg $(go env GOPROXY) to override the goproxy
2121ARG goproxy=https://proxy.golang.org
@@ -28,6 +28,9 @@ ENV GOEXPERIMENT=${CRYPTO_LIB:+boringcrypto}
2828FROM toolchain as builder
2929WORKDIR /workspace
3030
31+ RUN apk update
32+ RUN apk add git gcc g++ curl
33+
3134# Copy the Go Modules manifests
3235COPY go.mod go.mod
3336COPY go.sum go.sum
@@ -44,10 +47,15 @@ COPY ./ ./
4447ARG package=.
4548ARG ARCH
4649ARG LDFLAGS
47- RUN --mount=type=cache,target=/root/.cache/go-build \
50+ RUN --mount=type=cache,target=/root/.cache/go-build \
4851 --mount=type=cache,target=/go/pkg/mod \
4952 --mount=type=cache,target=/root/.local/share/golang \
50- CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -ldflags "${LDFLAGS} -extldflags '-static'" -o manager ${package}
53+ if [ ${CRYPTO_LIB} ]; \
54+ then \
55+ CGO_ENABLED=1 GOOS=linux GOARCH=${ARCH} go build -ldflags "${LDFLAGS} -linkmode=external -extldflags '-static'" -o manager ${package}; \
56+ else \
57+ CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -ldflags "${LDFLAGS} -extldflags '-static'" -o manager ${package}; \
58+ fi
5159ENTRYPOINT [ "/start.sh" , "/workspace/manager" ]
5260
5361# Copy the controller-manager into a thin image
0 commit comments