minor tweaks
This commit is contained in:
parent
c13f1ecea5
commit
9e83028509
@ -1,13 +1,14 @@
|
|||||||
FROM golang:1.18 as builder
|
FROM golang:1.20-alpine as builder
|
||||||
WORKDIR /go/src/app
|
WORKDIR /go/src/app
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN apt update && apt upgrade -y
|
#RUN apt update && apt upgrade -y
|
||||||
RUN go build
|
RUN CGO_ENABLED=0 go build
|
||||||
|
|
||||||
FROM alpine:latest as final
|
FROM alpine:latest as final
|
||||||
WORKDIR /srv/
|
WORKDIR /srv/
|
||||||
RUN mkdir /srv/dota_patch_bot
|
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
|
RUN apk add libc6-compat
|
||||||
|
#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/
|
COPY --from=builder /go/src/app/dota_patch_bot /srv/dota_patch_bot/
|
||||||
|
|
||||||
CMD ["/srv/dota_patch_bot/dota_patch_bot"]
|
CMD ["/srv/dota_patch_bot/dota_patch_bot"]
|
||||||
|
11
main.go
11
main.go
@ -5,7 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -37,7 +37,7 @@ func loadPatches(pl *patchList, url string) {
|
|||||||
}
|
}
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
|
|
||||||
body, readErr := ioutil.ReadAll(res.Body)
|
body, readErr := io.ReadAll(res.Body)
|
||||||
if readErr != nil {
|
if readErr != nil {
|
||||||
log.Fatal(readErr)
|
log.Fatal(readErr)
|
||||||
}
|
}
|
||||||
@ -48,7 +48,6 @@ func loadPatches(pl *patchList, url string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func notify(ptch patch, url string) {
|
func notify(ptch patch, url string) {
|
||||||
|
|
||||||
type Payload struct {
|
type Payload struct {
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
Format string `json:"format"`
|
Format string `json:"format"`
|
||||||
@ -96,9 +95,12 @@ func notify(ptch patch, url string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("error posting to webhook")
|
log.Println("error posting to webhook")
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
if resp.Body != nil {
|
||||||
|
resp.Body.Close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
hookPtr := flag.String("hook", "", "the webhook to notify")
|
hookPtr := flag.String("hook", "", "the webhook to notify")
|
||||||
sourcePtr := flag.String("url", "https://www.dota2.com/datafeed/patchnoteslist", "url to fetch patchnotes from")
|
sourcePtr := flag.String("url", "https://www.dota2.com/datafeed/patchnoteslist", "url to fetch patchnotes from")
|
||||||
@ -147,5 +149,4 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user