From 69d2c980acb6daa22691e1ba7b8973bfd747e581 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+WeebDataHoarder@users.noreply.github.com> Date: Sat, 22 Apr 2023 10:53:47 +0200 Subject: [PATCH] docker-compose setup --- .dockerignore | 6 ++++++ .env.example | 21 +++++++++++++++++++++ .gitignore | 4 +++- Dockerfile | 23 +++++++++++++++++++++++ docker-compose.yml | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 .env.example create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a3c779b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git/ +.env +.env.example +.gitignore +docker-compose.override.yml +README.md \ No newline at end of file diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..8d8f238 --- /dev/null +++ b/.env.example @@ -0,0 +1,21 @@ +#GOPROXY=direct + +# IRC host/port to connect to +IRC_HOST=irc.libera.chat +IRC_PORT=6697 + +# Bot configuration +BOT_NICK= +BOT_USER= +# ChanServ password +BOT_PASSWORD= + +# A list of #CHANNEL,NAME,API_ENDPOINT separated by; for example: #p2pool-main,Main,https://p2pool.observer;#p2pool-mini,Mini,https://mini.p2pool.observer +CHANNELS= + +# Pleroma host and cookie if any +PLEROMA_HOST= +PLEROMA_COOKIE= + +# Extra command line arguments like SSL +EXTRA_ARGS=-irc-ssl \ No newline at end of file diff --git a/.gitignore b/.gitignore index 723ef36..04e729a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -.idea \ No newline at end of file +.idea +.env.example +docker-compose.override.yml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d250818 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM golang:1.20-alpine + + +ENV CFLAGS="-march=native -Ofast" +ENV CXXFLAGS="-march=native -Ofast" +ENV LDFLAGS="-flto" +ENV CGO_CFLAGS="-march=native -Ofast" + +ENV CGO_ENABLED="0" + +WORKDIR /usr/src/p2pool-observer-bot + +ARG GOPROXY="" +ENV GOPROXY=${GOPROXY} + +COPY go.mod go.sum ./ +RUN go mod download -x && go mod verify + +COPY . . + +RUN go build -buildvcs=false -trimpath -v -o /usr/bin/bot git.gammaspectra.live/P2Pool/p2pool-observer-bot + +WORKDIR /data \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d537f09 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,33 @@ +version: "2.2" + +networks: + p2pool-observer-bot: + external: false + +volumes: + data: + external: false +services: + bot: + build: + context: ./ + dockerfile: ./Dockerfile + args: + - GOPROXY=${GOPROXY} + restart: always + environment: + - BOT_PASSWORD=${BOT_PASSWORD} + - PLEROMA_COOKIE=${PLEROMA_COOKIE} + security_opt: + - no-new-privileges:true + networks: + - p2pool-observer-bot + command: >- + /usr/bin/bot + -irc-host "${IRC_HOST}" + -irc-port "${IRC_PORT}" + -bot-nick "${BOT_NICK}" + -bot-user "${BOT_USER}" + -pleroma-host "${PLEROMA_HOST}" + -channels "${CHANNELS}" + ${P2POOL_EXTRA_ARGS} \ No newline at end of file