Browse Source

docker file + fmt

pull/1/head 1.0.0
Efertone 2 years ago
parent
commit
b21bd685d8
No known key found for this signature in database GPG Key ID: F484939122A96110
2 changed files with 20 additions and 10 deletions
  1. +11
    -0
      Dockerfile
  2. +9
    -10
      main.go

+ 11
- 0
Dockerfile View File

@ -0,0 +1,11 @@
FROM golang:latest as build
RUN go get -v github.com/sirupsen/logrus && \
go get -v github.com/mailgun/mailgun-go
COPY . /code
WORKDIR /code
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o /idlerpg-checker .
FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=build /idlerpg-checker /idlerpg-checker
ENTRYPOINT ["/idlerpg-checker"]

+ 9
- 10
main.go View File

@ -3,36 +3,36 @@ package main
import (
"context"
"crypto/tls"
"encoding/xml"
"flag"
"fmt"
"io/ioutil"
"net/http"
"encoding/xml"
"os"
"time"
log "github.com/sirupsen/logrus"
mailgun "github.com/mailgun/mailgun-go"
log "github.com/sirupsen/logrus"
)
const (
appVersion = "1.0.0"
infoURI = "https://idlerpg.lolhosting.net/xml.php"
appVersion = "1.0.0"
infoURI = "https://idlerpg.lolhosting.net/xml.php"
msgTemplate = `Dear %s
You seem to be offline based on https://idlerpg.lolhosting.net/xml.php?player=%s`
)
var (
domain = os.Getenv("MG_DOMAIN")
domain = os.Getenv("MG_DOMAIN")
mgAPIKey = os.Getenv("MG_API_KEY")
)
type Player struct {
XMLName xml.Name `xml:"player"`
Username string `xml:"username"`
Level int `xml:"level"`
Online bool `xml:"online"`
XMLName xml.Name `xml:"player"`
Username string `xml:"username"`
Level int `xml:"level"`
Online bool `xml:"online"`
}
func init() {
@ -67,7 +67,6 @@ func isOnline(username string) bool {
}
func sendEmailNotification(username string, email string) {
log.Infoln(mgAPIKey)
mg := mailgun.NewMailgun(domain, mgAPIKey)
sender := fmt.Sprintf("no-reply@%s", domain)


Loading…
Cancel
Save