-
Notifications
You must be signed in to change notification settings - Fork 1.5k
use minimal base docker image #2196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# syntax=docker/dockerfile:experimental | ||
|
||
FROM --platform=${BUILDPLATFORM} golang:1.16.3 AS base | ||
FROM --platform=${TARGETPLATFORM} golang:1.16 AS base | ||
WORKDIR /workspace | ||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod | ||
|
@@ -21,17 +21,11 @@ RUN --mount=type=bind,target=. \ | |
GOOS=${TARGETOS} GOARCH=${TARGETARCH} GO111MODULE=on \ | ||
CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2" \ | ||
CGO_LDFLAGS="-Wl,-z,relro,-z,now" \ | ||
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 | ||
|
||
FROM amazonlinux:2 as bin-unix | ||
|
||
RUN yum update -y && \ | ||
yum clean all && \ | ||
rm -rf /var/cache/yum | ||
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 | ||
|
||
FROM public.ecr.aws/eks-distro-build-tooling/eks-distro-minimal-base-nonroot:2021-08-22-1629654770 as bin-unix | ||
|
||
COPY --from=build /out/controller /controller | ||
USER 1002 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this included in the base image? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, the nonroot base image have a different USER set. |
||
ENTRYPOINT ["/controller"] | ||
|
||
FROM bin-unix AS bin-linux | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the change in the golang version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be consistent with our go.mod.
this will make sure we are using latest golang 1.16 series for new builds