From 7513414eb76f0eaa3013be3efb4aa28225a0316e Mon Sep 17 00:00:00 2001 From: josebarn Date: Tue, 15 Aug 2017 16:13:50 -0300 Subject: [PATCH] added publish step, and drone sig for secrets, plus dockerfile --- .drone.yml | 9 +++++++-- .drone.yml.sig | 1 + docker/Dockerfile | 23 +++++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 .drone.yml.sig create mode 100644 docker/Dockerfile diff --git a/.drone.yml b/.drone.yml index 8657b83..b15be94 100644 --- a/.drone.yml +++ b/.drone.yml @@ -9,8 +9,13 @@ pipeline: commands: - go test + publish: + image: plugins/docker + repo: josebarn/hello-world + tags: [ 1.0.0, 1.0, latest ] + dockerfile: ./docker/Dockerfile + secrets: [ docker_username, docker_password ] + matrix: IMAGE: - - golang:1.7 - - golang:1.8 - golang:latest diff --git a/.drone.yml.sig b/.drone.yml.sig new file mode 100644 index 0000000..9732a0f --- /dev/null +++ b/.drone.yml.sig @@ -0,0 +1 @@ +eyJhbGciOiJIUzI1NiJ9.cGlwZWxpbmU6CiAgYnVpbGQ6CiAgICBpbWFnZTogJHtJTUFHRX0KICAgIGNvbW1hbmRzOgogICAgICAtIGdvIGJ1aWxkCgogIHRlc3Q6CiAgICBpbWFnZTogJHtJTUFHRX0KICAgIGNvbW1hbmRzOgogICAgICAtIGdvIHRlc3QKCiAgcHVibGlzaDoKICAgIGltYWdlOiBwbHVnaW5zL2RvY2tlcgogICAgcmVwbzogam9zZWJhcm4vaGVsbG8td29ybGQKICAgIHRhZ3M6IFsgMS4wLjAsIDEuMCwgbGF0ZXN0IF0KICAgIGRvY2tlcmZpbGU6IC4vZG9ja2VyL0RvY2tlcmZpbGUKICAgIHNlY3JldHM6IFsgZG9ja2VyX3VzZXJuYW1lLCBkb2NrZXJfcGFzc3dvcmQgXQogICAgCm1hdHJpeDoKICBJTUFHRToKICAgIC0gZ29sYW5nOmxhdGVzdAo.35I5ulM7TJbhXqCZsiXBtPAVG0MzsDlsgrl_aZYuK10 \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..7a5354a --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,23 @@ +# Multi-stage build form +FROM golang:latest + +# Copy in code... +RUN mkdir /app +ADD main.go /app/ + +# Build app +WORKDIR /app +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o hello . + +# Could use something even smaller... +FROM alpine:latest +RUN apk --no-cache add ca-certificates + +RUN mkdir /app +WORKDIR /app/ +COPY --from=0 /app/hello . + +# Expose ports for future REST Interface +EXPOSE 8080 + +CMD ["/app/hello"]