Skip to content
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

Feature/Fix: Dockerfile - Make roughly 43% smaller #60

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Dockerfile
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"]