-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[security] default to run as non root user nobody (#26)
* Run as nobody user * Document update regarding hardening
- Loading branch information
Showing
2 changed files
with
27 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM --platform=$BUILDPLATFORM golang:1.16 | ||
FROM --platform=$BUILDPLATFORM golang:1.16 as build | ||
LABEL maintainer="Blake Covarrubias <[email protected]>" \ | ||
org.opencontainers.image.authors="Blake Covarrubias <[email protected]>" \ | ||
org.opencontainers.image.description="Advertises records for Kubernetes resources over multicast DNS." \ | ||
|
@@ -14,11 +14,15 @@ ARG TARGETVARIANT | |
ADD . /go/src/github.com/blake/external-mdns | ||
WORKDIR /go/src/github.com/blake/external-mdns | ||
|
||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=$(echo ${TARGETVARIANT} | cut -c2) \ | ||
RUN mkdir -p /release/etc &&\ | ||
echo nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin > /release/etc/passwd &&\ | ||
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=$(echo ${TARGETVARIANT} | cut -c2) \ | ||
go build \ | ||
-ldflags="-s -w" \ | ||
-o external-mdns . | ||
-o /release/external-mdns . | ||
|
||
|
||
FROM scratch | ||
COPY --from=0 /go/src/github.com/blake/external-mdns/external-mdns /external-mdns | ||
COPY --from=build /release / | ||
USER nobody | ||
ENTRYPOINT ["/external-mdns"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters