Skip to content

Commit 26f36bf

Browse files
M00nF1shTimothy-Dougherty
authored andcommitted
use minimal base docker image (kubernetes-sigs#2196)
1 parent 06012ed commit 26f36bf

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

Dockerfile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:experimental
22

3-
FROM --platform=${BUILDPLATFORM} golang:1.16.3 AS base
3+
FROM --platform=${TARGETPLATFORM} golang:1.16 AS base
44
WORKDIR /workspace
55
# Copy the Go Modules manifests
66
COPY go.mod go.mod
@@ -21,17 +21,11 @@ RUN --mount=type=bind,target=. \
2121
GOOS=${TARGETOS} GOARCH=${TARGETARCH} GO111MODULE=on \
2222
CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2" \
2323
CGO_LDFLAGS="-Wl,-z,relro,-z,now" \
24-
go build -ldflags="-s -w -X ${VERSION_PKG}.GitVersion=${GIT_VERSION} -X ${VERSION_PKG}.GitCommit=${GIT_COMMIT} -X ${VERSION_PKG}.BuildDate=${BUILD_DATE}" -buildmode=pie -mod=readonly -a -o /out/controller main.go
25-
26-
FROM amazonlinux:2 as bin-unix
27-
28-
RUN yum update -y && \
29-
yum clean all && \
30-
rm -rf /var/cache/yum
24+
go build -buildmode=pie -tags 'osusergo,netgo,static_build' -ldflags="-s -w -linkmode=external -extldflags '-static-pie' -X ${VERSION_PKG}.GitVersion=${GIT_VERSION} -X ${VERSION_PKG}.GitCommit=${GIT_COMMIT} -X ${VERSION_PKG}.BuildDate=${BUILD_DATE}" -mod=readonly -a -o /out/controller main.go
3125

26+
FROM public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:2021-08-22-1629654770 as bin-unix
3227

3328
COPY --from=build /out/controller /controller
34-
USER 1002
3529
ENTRYPOINT ["/controller"]
3630

3731
FROM bin-unix AS bin-linux

0 commit comments

Comments
 (0)