diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..1e7cf97 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,23 @@ +pipeline: + build: + image: golang + commands: + - go get -d ./... + - go build . + publish: + image: plugins/docker + repo: klmp200/alfred + secrets: [ docker_username, docker_password ] + when: + branch: master + deploy: + image: appleboy/drone-ssh + host: + - ollivander.diagon-alley + username: dronedeploy + secrets: [ ssh_password ] + envs: [ ssh_password ] + script: + - echo $SSH_PASSWORD | sudo -S systemctl restart alfred-bot + when: + branch: master \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3fb3ebd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM golang:1.10 AS builder + +# Download and install the latest release of dep +# ADD https://github.com/golang/dep/releases/download/v0.4.1/dep-linux-amd64 /usr/bin/dep +# RUN chmod +x /usr/bin/dep + +# Copy the code from the host and compile it +COPY . ./ + +RUN go get -v -d ./... + +RUN mkdir res + +COPY settings.json res + +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix nocgo -o /app . + +# We use Alpine for it's ca-certificates needed by http lib +FROM alpine:3.4 +RUN apk add --no-cache ca-certificates apache2-utils +COPY --from=builder /app ./ +COPY --from=builder /go/res ./ + + +ENTRYPOINT ["./app"]