tpotce/docker/glutton/Dockerfile

50 lines
1.3 KiB
Text
Raw Normal View History

FROM golang:1.21-alpine as builder
2019-10-15 14:50:39 +00:00
#
2018-04-13 18:22:49 +00:00
# Include dist
2022-03-08 23:36:03 +00:00
COPY dist/ /root/dist/
2019-10-15 14:50:39 +00:00
#
2018-04-13 18:22:49 +00:00
# Setup apk
RUN apk -U --no-cache add \
2024-05-07 12:26:18 +00:00
make \
git \
g++ \
iptables-dev \
libpcap-dev && \
2019-10-15 14:50:39 +00:00
#
2018-04-13 18:22:49 +00:00
# Setup go, glutton
mkdir -p /opt/ && \
cd /opt/ && \
2019-10-15 14:50:39 +00:00
git clone https://github.com/mushorg/glutton && \
cd /opt/glutton/ && \
git checkout c1204c65ce32bfdc0e08fb2a9abe89b3b8eeed62 && \
cp /root/dist/system.go . && \
2018-04-13 18:22:49 +00:00
make build && \
mv /root/dist/config.yaml /opt/glutton/config/
#
FROM alpine:3.19
#
COPY --from=builder /opt/glutton/bin /opt/glutton/bin
COPY --from=builder /opt/glutton/config /opt/glutton/config
COPY --from=builder /opt/glutton/rules /opt/glutton/rules
#
RUN apk -U --no-cache add \
iptables-dev \
2024-05-07 12:26:18 +00:00
libpcap-dev && \
setcap cap_net_admin,cap_net_raw=+ep /opt/glutton/bin/server && \
setcap cap_net_admin,cap_net_raw=+ep /sbin/xtables-nft-multi && \
mkdir -p /var/log/glutton \
/opt/glutton/payloads && \
2019-10-15 14:50:39 +00:00
#
2018-04-13 18:22:49 +00:00
# Setup user, groups and configs
addgroup -g 2000 glutton && \
2018-05-18 15:40:07 +00:00
adduser -S -s /bin/ash -u 2000 -D -g 2000 glutton && \
2019-10-15 14:50:39 +00:00
#
2018-04-13 18:22:49 +00:00
# Clean up
rm -rf /var/cache/apk/* \
2022-03-08 23:36:03 +00:00
/root/*
2019-10-15 14:50:39 +00:00
#
2018-05-16 16:37:41 +00:00
# Start glutton
2018-04-13 18:22:49 +00:00
WORKDIR /opt/glutton
USER glutton:glutton
CMD exec bin/server -d true -i $(/sbin/ip address show | /usr/bin/awk '/inet.*brd/{ print $NF; exit }') -l /var/log/glutton/glutton.log > /dev/null 2>&1