From 17293463f64a8ee15daefdb0322ff1421a13d88a Mon Sep 17 00:00:00 2001 From: Hamcha Date: Mon, 26 Aug 2019 12:39:30 +0200 Subject: [PATCH] Add drone/dockerfile --- .drone.yml | 33 +++++++++++++++++++++++++++++++++ Dockerfile | 20 ++++++++++++++++++++ main.go | 5 +++++ 3 files changed, 58 insertions(+) create mode 100644 .drone.yml create mode 100644 Dockerfile diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..4c3df3d --- /dev/null +++ b/.drone.yml @@ -0,0 +1,33 @@ +kind: pipeline +name: default + +steps: + - name: build + image: golang + commands: + - GOPROXY=https://modules.fromouter.space go mod download + - CGO_ENABLED=0 go install . + volumes: + - name: gopath + path: /go + + - name: publish + image: plugins/docker + settings: + auto_tag: true + dockerfile: Dockerfile + repo: hamcha/mlpcardbot + target: final + username: + from_secret: docker_username + password: + from_secret: docker_password + when: + event: + - push + - tag + branch: master + +volumes: + - name: gopath + temp: {} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ffd1e0c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +FROM golang:alpine AS builder + +ENV GOPROXY https://modules.fromouter.space +ENV GO111MODULE=on + +WORKDIR /app + +# Get updated modules +COPY ./ ./ +RUN go mod download + +# Compile code +RUN CGO_ENABLED=0 go build -o /svc . + +FROM scratch AS final + +# Import the compiled executable from the first stage. +COPY --from=builder /svc /svc + +CMD [ "/svc" ] \ No newline at end of file diff --git a/main.go b/main.go index 604209d..ef463e7 100644 --- a/main.go +++ b/main.go @@ -1,8 +1,10 @@ package main import ( + "crypto/tls" "fmt" "log" + "net/http" "os" "strconv" "strings" @@ -60,6 +62,9 @@ func main() { cfg.MaxRequestsPerMessage = 5 } + // Ignore CA errors + http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + api = tg.MakeAPIClient(token) api.SetWebhook(webhookURL) api.HandleWebhook(bind, webhookPath, webhook)