Skip to content

Commit c269d12

Browse files
authored
use minimal base docker image (#2197)
1 parent 0521a6b commit c269d12

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
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.15.0 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

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module sigs.k8s.io/aws-load-balancer-controller
22

3-
go 1.13
3+
go 1.16
44

55
require (
66
github.com/aws/aws-sdk-go v1.40.10

0 commit comments

Comments
 (0)