tpotce/docker/glutton/Dockerfile

55 lines
1.7 KiB
Text
Raw Normal View History

2018-04-13 18:22:49 +00:00
FROM alpine
# Include dist
ADD dist/ /root/dist/
# Setup apk
2018-05-18 15:40:07 +00:00
RUN apk -U --no-cache add \
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 && \
2018-04-13 18:22:49 +00:00
# Setup go, glutton
export GOPATH=/opt/go/ && \
go get -d github.com/mushorg/glutton && \
2018-08-30 16:19:11 +00:00
cd /opt/go/src/github.com/satori/ && \
rm -rf go.uuid && \
git clone https://github.com/satori/go.uuid && \
cd go.uuid && \
git checkout v1.2.0 && \
2018-05-18 20:47:54 +00:00
mv /root/dist/system.go /opt/go/src/github.com/mushorg/glutton/ && \
2018-04-13 18:22:49 +00:00
cd /opt/go/src/github.com/mushorg/glutton/ && \
make build && \
cd / && \
mkdir -p /opt/glutton && \
mv /opt/go/src/github.com/mushorg/glutton/bin /opt/glutton/ && \
mv /opt/go/src/github.com/mushorg/glutton/config /opt/glutton/ && \
mv /opt/go/src/github.com/mushorg/glutton/rules /opt/glutton/ && \
2018-05-18 20:05:52 +00:00
setcap cap_net_admin,cap_net_raw=+ep /opt/glutton/bin/server && \
setcap cap_net_admin,cap_net_raw=+ep /sbin/xtables-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/ && \
# 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
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
2018-04-16 22:05:16 +00:00
CMD exec bin/server -i $(/sbin/ip address | grep '^2: ' | awk '{ print $2 }' | tr -d [:punct:]) -l /var/log/glutton/glutton.log