multi stage build for dicompot
rebuild fatt, glutton, hellpot, honeypots for alpine 3.19
bump glutton, hellpot, honeypots to latest master
This commit is contained in:
t3chn0m4g3
2024-03-05 19:50:35 +01:00
parent 519a101fdf
commit c45870594b
66 changed files with 464 additions and 225 deletions

View File

@ -1,46 +1,41 @@
FROM alpine:3.17
FROM golang:1.21-alpine as builder
#
# Include dist
COPY dist/ /root/dist/
#
# Setup apk
RUN apk -U --no-cache add \
build-base \
git \
go \
g++ && \
build-base \
git \
g++ && \
#
# Setup go, hellpot
cd /root && \
export GOPATH=/opt/go/ && \
mkdir -p /opt/hellpot && \
mkdir -p /opt/go && \
git clone https://github.com/yunginnanet/HellPot && \
cd HellPot && \
git checkout 49433bf499b6af314786cbbc3cb8566cdb18c40c && \
git checkout 3673ab0228664fb3acd33102be5c7a5867137eb5 && \
# git checkout 49433bf499b6af314786cbbc3cb8566cdb18c40c && \
sed -i 's#logFileName := "HellPot"#logFileName := "hellpot"#g' internal/config/logger.go && \
go build cmd/HellPot/HellPot.go && \
mv /root/HellPot/HellPot /opt/hellpot/ && \
go mod download && \
go vet -v ./... && \
go test -v ./... && \
export CGO_ENABLED=0 && \
export VERSION=`git tag --sort=-version:refname | head -n 1` && \
go build -trimpath \
-ldflags "-s -w -X main.version=$VERSION" \
cmd/HellPot/HellPot.go
#
FROM alpine:3.19
#
COPY --from=builder /root/HellPot/HellPot /opt/hellpot/
COPY --from=builder /root/dist/config.toml /opt/hellpot/config/
#
# Setup user, groups and configs
addgroup -g 2000 hellpot && \
RUN addgroup -g 2000 hellpot && \
adduser -S -s /bin/ash -u 2000 -D -g 2000 hellpot && \
mkdir -p /var/log/hellpot && \
# Hellpot wants to create .config folder always in user's home
mkdir -p /home/hellpot/.config/HellPot/logs && \
mv /root/dist/config.toml /home/hellpot/.config/HellPot/ && \
chown hellpot:hellpot -R /home/hellpot && \
#
# Clean up
apk del --purge build-base \
git \
go \
g++ && \
rm -rf /var/cache/apk/* \
/opt/go \
/root/*
mkdir -p /var/log/hellpot
#
# Start hellpot
WORKDIR /opt/hellpot
USER hellpot:hellpot
CMD ["./HellPot"]
CMD ["./HellPot", "-c","config/config.toml"]