From c13f1ecea57fdc2417a0c1654f3a277119bbca4d Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 10 Aug 2022 21:19:34 -0400 Subject: [PATCH] use env variables, containerfile --- .containerignore | 7 +++++++ Containerfile | 13 +++++++++++++ main.go | 11 +++++++++++ 3 files changed, 31 insertions(+) create mode 100644 .containerignore create mode 100644 Containerfile diff --git a/.containerignore b/.containerignore new file mode 100644 index 0000000..1819fcb --- /dev/null +++ b/.containerignore @@ -0,0 +1,7 @@ +.git +.gitignore +Dockerfile* +Containerfile* +README.md +LICENSE +*.yaml diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..ee89379 --- /dev/null +++ b/Containerfile @@ -0,0 +1,13 @@ +FROM golang:1.18 as builder +WORKDIR /go/src/app +COPY . . +RUN apt update && apt upgrade -y +RUN go build + +FROM alpine:latest as final +WORKDIR /srv/ +RUN mkdir /srv/dota_patch_bot +RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 +COPY --from=builder /go/src/app/dota_patch_bot /srv/dota_patch_bot/ + +CMD ["/srv/dota_patch_bot/dota_patch_bot"] diff --git a/main.go b/main.go index daf17e5..09403c4 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "io/ioutil" "log" "net/http" + "os" "time" ) @@ -105,6 +106,16 @@ func main() { var currentPatch patch flag.Parse() + if *hookPtr == "" { + if val, ok := os.LookupEnv("DOTA_WEBHOOK"); ok { + *hookPtr = val + } + } + if *sourcePtr == "" { + if val, ok := os.LookupEnv("DOTA_PATCH_SOURCE"); ok { + *sourcePtr = val + } + } loadPatches(&patchlist, *sourcePtr) if len(patchlist.Patches) <= 0 {