forked from Gandem/bonjour-reflector
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dockerfile: Make roughly 43% smaller
- Loading branch information
1 parent
669ade1
commit c9eb5a9
Showing
1 changed file
with
8 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,19 +1,23 @@ | ||
FROM golang:alpine as gobuild | ||
|
||
RUN apk add --no-cache libpcap-dev git gcc libc-dev libcap-utils | ||
RUN apk add --no-cache libpcap-dev git gcc libc-dev libcap-utils upx | ||
WORKDIR github.com/nberlee/bonjour-reflector | ||
COPY go.* . | ||
COPY *.go . | ||
RUN GOOS=linux go build -ldflags="-s -w" | ||
RUN upx bonjour-reflector | ||
RUN setcap cap_net_raw+ep bonjour-reflector | ||
|
||
|
||
FROM alpine as rootfs | ||
RUN apk --no-cache add libpcap | ||
COPY --from=gobuild /go/github.com/nberlee/bonjour-reflector/bonjour-reflector / | ||
RUN find /usr/bin /usr/sbin /sbin /bin -type l -delete && busybox grep -v libpcap /etc/apk/world | busybox xargs apk del | ||
|
||
|
||
FROM scratch as intermediate | ||
COPY --from=rootfs /lib/*musl* /lib/ | ||
COPY --from=rootfs /usr/lib/*pcap* /usr/lib/ | ||
COPY --from=gobuild /go/github.com/nberlee/bonjour-reflector/bonjour-reflector /bonjour-reflector | ||
|
||
FROM scratch | ||
COPY --from=rootfs / / | ||
COPY --from=intermediate / / | ||
CMD ["/bonjour-reflector"] |