From 8640c530936d4ae443af0e115967a3aae9e5f014 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Wed, 11 May 2016 15:14:25 +0200 Subject: [PATCH] Manually build terraform To avoid the installation of packages that are not part of the official Alpine distribution I have integrated a similar bahavior as we already have for the drone-cloudfoundry plugin. I'm downloading the terraform sources and I'm building the binary together with drone-terraform. Signed-off-by: Thomas Boerger --- Dockerfile | 19 +++++++------------ Makefile | 3 +++ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index f8c7e7e..ef6d324 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,14 @@ -# Docker image for Drone's terraform deployment plugin +# Docker image for the Drone Cloud Foundry plugin # -# CGO_ENABLED=0 go build -a -tags netgo -# docker build --rm=true -t plugins/drone-terraform . +# cd $GOPATH/src/github.com/drone-plugins/drone-terraform +# make deps build docker -FROM gliderlabs/alpine:3.2 -RUN apk-install ca-certificates - -ENV TERRAFORM_VERSION 0.6.14 +FROM alpine:3.2 RUN apk update && \ - wget -q "https://circle-artifacts.com/gh/andyshinn/alpine-pkg-glibc/6/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64/glibc-2.21-r2.apk" && \ - apk add --allow-untrusted glibc-2.21-r2.apk && \ - wget -q -O terraform.zip "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" && \ - unzip terraform.zip -d /bin && \ - rm -rf /var/cache/apk/* glibc-2.21-r2.apk terraform.zip + apk add ca-certificates && \ + rm -rf /var/cache/apk/* +ADD terraform /bin/ ADD drone-terraform /bin/ ENTRYPOINT ["/bin/drone-terraform"] diff --git a/Makefile b/Makefile index 0dc93e2..232f851 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,7 @@ clean: go clean -i ./... deps: + go get -d github.com/hashicorp/terraform go get -t ./... fmt: @@ -25,10 +26,12 @@ test: @for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done; docker: + GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o terraform github.com/hashicorp/terraform GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '-s -w $(LDFLAGS)' docker build --rm -t $(IMAGE) . $(EXECUTABLE): $(wildcard *.go) + go build -o terraform github.com/hashicorp/terraform go build -ldflags '-s -w $(LDFLAGS)' build: $(EXECUTABLE)