Add drone/dockerfile

This commit is contained in:
Hamcha 2019-08-26 12:39:30 +02:00
parent 39da857f03
commit 17293463f6
Signed by: hamcha
GPG key ID: 44AD3571EB09A39E
3 changed files with 58 additions and 0 deletions

33
.drone.yml Normal file
View file

@ -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: {}

20
Dockerfile Normal file
View file

@ -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" ]

View file

@ -1,8 +1,10 @@
package main package main
import ( import (
"crypto/tls"
"fmt" "fmt"
"log" "log"
"net/http"
"os" "os"
"strconv" "strconv"
"strings" "strings"
@ -60,6 +62,9 @@ func main() {
cfg.MaxRequestsPerMessage = 5 cfg.MaxRequestsPerMessage = 5
} }
// Ignore CA errors
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
api = tg.MakeAPIClient(token) api = tg.MakeAPIClient(token)
api.SetWebhook(webhookURL) api.SetWebhook(webhookURL)
api.HandleWebhook(bind, webhookPath, webhook) api.HandleWebhook(bind, webhookPath, webhook)