From 5e577232e4f8cc4d27871174f2eb4ea19907f7e5 Mon Sep 17 00:00:00 2001 From: Joachim Hill-Grannec Date: Mon, 4 Sep 2017 13:43:03 -0400 Subject: [PATCH] Update to terraform 0.10.3 Added arm, arm64 and windows dockerfiles Changes to dockerfile should reduce size Update to readme for extra badges (same as drone-plugins) Should just need to uncomment and fix tags to auto-publish to docker hub --- .drone.yml | 105 +++++++++++++++++++++++++++++++++++++++++++-- Dockerfile | 27 +++++++----- Dockerfile.arm | 21 +++++++++ Dockerfile.arm64 | 21 +++++++++ Dockerfile.windows | 13 ++++++ README.md | 6 ++- 6 files changed, 178 insertions(+), 15 deletions(-) create mode 100644 Dockerfile.arm create mode 100644 Dockerfile.arm64 create mode 100644 Dockerfile.windows diff --git a/.drone.yml b/.drone.yml index 49045d3..2b43eb6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,12 +1,109 @@ workspace: base: /go - path: src/github.com/drone-plugins/drone-terraform + path: src/github.com/jmccann/drone-terraform pipeline: test: - image: golang:1.8 + image: golang:1.9 + pull: true + commands: + - go vet + - go test -cover -coverprofile=coverage.out + + build_linux_amd64: + image: golang:1.9 + pull: true + group: build environment: + - GOOS=linux + - GOARCH=amd64 - CGO_ENABLED=0 commands: - - go test -cover -coverprofile=coverage.out - - go build -ldflags "-s -w -X main.revision=$(git rev-parse HEAD)" -a + - go build -v -ldflags "-X main.revision=$(git rev-parse HEAD)" -a -o release/linux/amd64/${DRONE_REPO_NAME} + +# build_linux_arm64: +# image: golang:1.9 +# pull: true +# group: build +# environment: +# - GOOS=linux +# - GOARCH=arm64 +# - CGO_ENABLED=0 +# commands: +# - go build -v -ldflags "-X main.revision=$(git rev-parse HEAD)" -a -o release/linux/arm64/${DRONE_REPO_NAME} + + build_linux_arm: + image: golang:1.9 + pull: true + group: build + environment: + - GOOS=linux + - GOARCH=arm + - CGO_ENABLED=0 + - GOARM=7 + commands: + - go build -v -ldflags "-X main.revision=$(git rev-parse HEAD)" -a -o release/linux/arm/${DRONE_REPO_NAME} + + # build_windows_amd64: + # image: golang:1.9-nanoserver + # pull: true + # group: build + # environment: + # - GOOS=windows + # - GOARCH=amd64 + # - CGO_ENABLED=0 + # commands: + # - go build -v -ldflags "-X main.build=${DRONE_BUILD_NUMBER}" -a -o release/windows/amd64/${DRONE_REPO_NAME} + +# publish_linux_amd64: +# image: plugins/docker:17.05 +# pull: true +# repo: jmccann/${DRONE_REPO_NAME} +# tags: [ latest, 1.0.0, 1.0, 1 ] +# secrets: [ docker_username, docker_password ] +# dockerfile: Dockerfile +# when: +# branch: master +# event: push + +# publish_linux_arm64: +# image: plugins/docker:17.05 +# pull: true +# repo: jmccann/${DRONE_REPO_NAME} +# tags: [ linux-arm64 ] +# secrets: [ docker_username, docker_password ] +# dockerfile: Dockerfile.arm64 +# when: +# branch: master +# event: push +# +# publish_linux_arm: +# image: plugins/docker:17.05 +# pull: true +# repo: jmccann/${DRONE_REPO_NAME} +# tags: [ linux-arm ] +# secrets: [ docker_username, docker_password ] +# dockerfile: Dockerfile.arm +# when: +# branch: master +# event: push + + # publish_windows_amd64: + # image: plugins/docker:17.05 + # pull: true + # repo: jmccann/${DRONE_REPO_NAME} + # tags: [ windows-amd64 ] + # secrets: [ docker_username, docker_password ] + # dockerfile: Dockerfile.windows + # when: + # branch: master + # event: push + +# microbadger: +# image: plugins/webhook:1 +# pull: true +# secrets: [ webhook_url ] +# when: +# branch: master +# event: push +# status: [ success ] diff --git a/Dockerfile b/Dockerfile index 2082ebc..a173baa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,26 @@ # Docker image for the Drone Terraform plugin # # docker build --rm=true -t jmccann/drone-terraform:latest . +FROM alpine:3.6 as alpine +RUN apk add -U --no-cache ca-certificates git wget -FROM alpine:3.4 - -RUN apk -U add \ - ca-certificates \ - git \ - wget && \ - rm -rf /var/cache/apk/* - -ENV TERRAFORM_VERSION 0.9.11 +ENV TERRAFORM_VERSION 0.10.3 RUN wget -q https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -O terraform.zip && \ unzip terraform.zip -d /bin && \ rm -f terraform.zip -ADD drone-terraform /bin/ +FROM scratch + +ENV GODEBUG=netdns=go +COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +COPY --from=alpine /bin/terraform /bin/terraform + + + +LABEL org.label-schema.version=latest +LABEL org.label-schema.vcs-url="https://github.com/jmccann/drone-terraform.git" +LABEL org.label-schema.name="Drone Terraform" +LABEL org.label-schema.vendor="jmccann" + +ADD release/linux/amd64/drone-terraform /bin/ ENTRYPOINT ["/bin/drone-terraform"] diff --git a/Dockerfile.arm b/Dockerfile.arm new file mode 100644 index 0000000..89323f5 --- /dev/null +++ b/Dockerfile.arm @@ -0,0 +1,21 @@ +FROM alpine:3.6 as alpine +RUN apk add -U --no-cache ca-certificates git wget + +ENV TERRAFORM_VERSION 0.10.3 +RUN wget -q https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_arm.zip -O terraform.zip && \ + unzip terraform.zip -d /bin && \ + rm -f terraform.zip + +FROM scratch + +ENV GODEBUG=netdns=go + +COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ + +LABEL org.label-schema.version=latest +LABEL org.label-schema.vcs-url="https://github.com/jmccann/drone-terraform.git" +LABEL org.label-schema.name="Drone Terraform" +LABEL org.label-schema.vendor="jmccann" + +ADD release/linux/arm/drone-terraform /bin/ +ENTRYPOINT ["/bin/drone-terraform"] \ No newline at end of file diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 new file mode 100644 index 0000000..043997a --- /dev/null +++ b/Dockerfile.arm64 @@ -0,0 +1,21 @@ +FROM alpine:3.6 as alpine +RUN apk add -U --no-cache ca-certificates + +ENV TERRAFORM_VERSION 0.10.3 +RUN wget -q https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_arm.zip -O terraform.zip && \ + unzip terraform.zip -d /bin && \ + rm -f terraform.zip + +FROM scratch + +ENV GODEBUG=netdns=go + +COPY --from=alpine /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ + +LABEL org.label-schema.version=latest +LABEL org.label-schema.vcs-url="https://github.com/jmccann/drone-terraform.git" +LABEL org.label-schema.name="Drone Terraform" +LABEL org.label-schema.vendor="jmccann" + +ADD release/linux/arm64/drone-terraform /bin/ +ENTRYPOINT ["/bin/drone-terraform"] \ No newline at end of file diff --git a/Dockerfile.windows b/Dockerfile.windows new file mode 100644 index 0000000..03822c2 --- /dev/null +++ b/Dockerfile.windows @@ -0,0 +1,13 @@ +FROM microsoft/nanoserver:latest + +ENV GODEBUG=netdns=go + +ENV TERRAFORM_VERSION 0.10.3 + +LABEL org.label-schema.version=latest +LABEL org.label-schema.vcs-url="https://github.com/jmccann/drone-terraform.git" +LABEL org.label-schema.name="Drone Terraform" +LABEL org.label-schema.vendor="jmccann" + +ADD release/windows/amd64/drone-terraform /bin/ +ENTRYPOINT [ "/bin/drone-terraform" ] \ No newline at end of file diff --git a/README.md b/README.md index 86821a6..148f450 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # drone-terraform [![Build Status](http://beta.drone.io/api/badges/jmccann/drone-terraform/status.svg)](http://beta.drone.io/jmccann/drone-terraform) +[![Join the chat at https://gitter.im/drone/drone](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/drone/drone) +[![Go Doc](https://godoc.org/github.com/jmccann/drone-terraform?status.svg)](http://godoc.org/github.com/jmccann/drone-terraform) +[![Go Report](https://goreportcard.com/badge/github.com/jmccann/drone-terraform)](https://goreportcard.com/report/github.com/jmccann/drone-terraform) +[![](https://images.microbadger.com/badges/image/jmccann/drone-terraform.svg)](https://microbadger.com/images/jmccann/drone-terraform "Get your own image badge on microbadger.com") Drone plugin to execute Terraform plan and apply. For the usage information and a listing of the available options please take a look at [the docs](DOCS.md). @@ -19,7 +23,7 @@ go test Build the docker image with the following commands: ``` -CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo +CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo -o release/linux/amd64/drone-terraform docker build --rm=true -t jmccann/drone-terraform . ```