File tree Expand file tree Collapse file tree 3 files changed +43
-3
lines changed
Expand file tree Collapse file tree 3 files changed +43
-3
lines changed Original file line number Diff line number Diff line change 1+ *
2+
3+ ! go.mod
4+ ! go.sum
5+ ! * .go
Original file line number Diff line number Diff line change 1+ FROM golang:1.20-bookworm AS build
2+
3+ RUN apt-get update && \
4+ apt-get install -y --no-install-recommends bison flex && \
5+ rm -r /var/lib/apt/*
6+
7+ WORKDIR /build
8+
9+ ENV LIBPCAP_VERSION=1.10.4
10+ RUN wget http://www.tcpdump.org/release/libpcap-${LIBPCAP_VERSION}.tar.gz && \
11+ tar xvf libpcap-${LIBPCAP_VERSION}.tar.gz && \
12+ cd libpcap-${LIBPCAP_VERSION} && \
13+ ./configure && \
14+ make
15+
16+ COPY . /build
17+
18+ ENV LD_LIBRARY_PATH="-L/build/libpcap-${LIBPCAP_VERSION}" \
19+ CGO_LDFLAGS="-L/build/libpcap-${LIBPCAP_VERSION}" \
20+ CGO_CPPFLAGS="-I/build/libpcap-${LIBPCAP_VERSION}"
21+ RUN GOOS=linux GOARCH=amd64 go build -ldflags "-linkmode 'external' -extldflags '-static' -s -w" -o bin/iptables-tracer .
22+
23+ # ###################
24+
25+ FROM scratch AS binary
26+ WORKDIR /bin
27+ COPY --from=build /build/bin/iptables-tracer /bin/
Original file line number Diff line number Diff line change 1- .PHONY : build
2- build :
1+ IMAGE_TAG = akerouanton/iptables-tracer:latest
2+ BUILD_OPTS =
3+
4+ ifdef BUILDER
5+ BUILD_OPTS := --builder=${BUILDER}
6+ endif
7+
8+ .PHONY : binary
9+ binary :
310 if [ ! -d bin/ ]; then mkdir bin; fi
4- go build -o bin/iptables-tracer ./
11+ docker build ${BUILD_OPTS} -t ${IMAGE_TAG} --target=binary .
12+ undock --include=/bin docker-daemon://${IMAGE_TAG} .
513
614install :
715 sudo cp bin/iptables-tracer /usr/local/sbin/iptables-tracer
You can’t perform that action at this time.
0 commit comments