2024-03-05 18:50:35 +00:00
|
|
|
FROM golang:1.21-alpine as builder
|
2021-07-02 22:12:47 +00:00
|
|
|
#
|
|
|
|
# Include dist
|
2022-03-08 23:36:03 +00:00
|
|
|
COPY dist/ /root/dist/
|
2021-07-02 22:12:47 +00:00
|
|
|
#
|
|
|
|
# Setup apk
|
|
|
|
RUN apk -U --no-cache add \
|
2024-03-05 18:50:35 +00:00
|
|
|
build-base \
|
|
|
|
git \
|
|
|
|
g++ && \
|
2021-07-02 22:12:47 +00:00
|
|
|
#
|
|
|
|
# Setup go, hellpot
|
2021-07-03 15:51:32 +00:00
|
|
|
cd /root && \
|
2021-07-02 22:12:47 +00:00
|
|
|
git clone https://github.com/yunginnanet/HellPot && \
|
|
|
|
cd HellPot && \
|
2024-03-05 18:50:35 +00:00
|
|
|
git checkout 3673ab0228664fb3acd33102be5c7a5867137eb5 && \
|
|
|
|
# git checkout 49433bf499b6af314786cbbc3cb8566cdb18c40c && \
|
2022-10-14 14:55:28 +00:00
|
|
|
sed -i 's#logFileName := "HellPot"#logFileName := "hellpot"#g' internal/config/logger.go && \
|
2024-03-05 18:50:35 +00:00
|
|
|
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/
|
2021-07-02 22:12:47 +00:00
|
|
|
#
|
|
|
|
# Setup user, groups and configs
|
2024-03-05 18:50:35 +00:00
|
|
|
RUN addgroup -g 2000 hellpot && \
|
2021-07-02 22:12:47 +00:00
|
|
|
adduser -S -s /bin/ash -u 2000 -D -g 2000 hellpot && \
|
2024-03-05 18:50:35 +00:00
|
|
|
mkdir -p /var/log/hellpot
|
2021-07-02 22:12:47 +00:00
|
|
|
#
|
|
|
|
# Start hellpot
|
|
|
|
WORKDIR /opt/hellpot
|
|
|
|
USER hellpot:hellpot
|
2024-03-05 18:50:35 +00:00
|
|
|
CMD ["./HellPot", "-c","config/config.toml"]
|