2020-02-25 16:59:22 +00:00
|
|
|
FROM alpine:latest
|
2019-10-15 14:50:39 +00:00
|
|
|
#
|
2018-04-13 18:22:49 +00:00
|
|
|
# Include dist
|
|
|
|
ADD dist/ /root/dist/
|
2019-10-15 14:50:39 +00:00
|
|
|
#
|
2018-04-13 18:22:49 +00:00
|
|
|
# Setup apk
|
2020-02-25 16:59:22 +00:00
|
|
|
RUN sed -i 's/dl-cdn/dl-2/g' /etc/apk/repositories && \
|
|
|
|
apk -U --no-cache add \
|
2018-05-18 15:40:07 +00:00
|
|
|
build-base \
|
|
|
|
git \
|
|
|
|
go \
|
|
|
|
g++ \
|
|
|
|
iptables-dev \
|
|
|
|
libnetfilter_queue-dev \
|
2018-05-18 20:05:52 +00:00
|
|
|
libcap \
|
2018-05-18 15:40:07 +00:00
|
|
|
libpcap-dev && \
|
2019-10-15 14:50:39 +00:00
|
|
|
#
|
2018-04-13 18:22:49 +00:00
|
|
|
# Setup go, glutton
|
|
|
|
export GOPATH=/opt/go/ && \
|
2019-10-15 14:50:39 +00:00
|
|
|
export GO111MODULE=on && \
|
|
|
|
mkdir -p /opt/go && \
|
|
|
|
cd /opt/go/ && \
|
|
|
|
git clone https://github.com/mushorg/glutton && \
|
|
|
|
cd /opt/go/glutton/ && \
|
|
|
|
mv /root/dist/system.go /opt/go/glutton/ && \
|
|
|
|
go mod download && \
|
2018-04-13 18:22:49 +00:00
|
|
|
make build && \
|
|
|
|
cd / && \
|
|
|
|
mkdir -p /opt/glutton && \
|
2019-10-15 14:50:39 +00:00
|
|
|
mv /opt/go/glutton/bin /opt/glutton/ && \
|
|
|
|
mv /opt/go/glutton/config /opt/glutton/ && \
|
|
|
|
mv /opt/go/glutton/rules /opt/glutton/ && \
|
|
|
|
ln -s /sbin/xtables-legacy-multi /sbin/xtables-multi && \
|
2018-05-18 20:05:52 +00:00
|
|
|
setcap cap_net_admin,cap_net_raw=+ep /opt/glutton/bin/server && \
|
2019-10-15 14:50:39 +00:00
|
|
|
setcap cap_net_admin,cap_net_raw=+ep /sbin/xtables-legacy-multi && \
|
|
|
|
#
|
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 && \
|
2018-04-13 18:22:49 +00:00
|
|
|
mkdir -p /var/log/glutton && \
|
|
|
|
mv /root/dist/rules.yaml /opt/glutton/rules/ && \
|
2019-10-15 14:50:39 +00:00
|
|
|
#
|
2018-04-13 18:22:49 +00:00
|
|
|
# Clean up
|
|
|
|
apk del --purge build-base \
|
|
|
|
git \
|
|
|
|
go \
|
2018-05-18 15:40:07 +00:00
|
|
|
g++ && \
|
2018-04-13 18:22:49 +00:00
|
|
|
rm -rf /var/cache/apk/* \
|
|
|
|
/opt/go \
|
|
|
|
/root/dist
|
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
|
2018-05-18 20:05:52 +00:00
|
|
|
USER glutton:glutton
|
2019-10-15 14:50:39 +00:00
|
|
|
CMD exec bin/server -i $(/sbin/ip address | grep '^2: ' | awk '{ print $2 }' | tr -d [:punct:]) -l /var/log/glutton/glutton.log > /dev/null 2>&1
|