From a22d272a0b6adf47816728ef6e6796cdbaf3022f Mon Sep 17 00:00:00 2001 From: Jacob McCann Date: Fri, 22 Feb 2019 08:40:57 -0600 Subject: [PATCH] chore: update instructions and Dockerbuild to work with modules --- .dockerignore | 1 + Dockerfile | 16 ++++++++++------ README.md | 13 +++---------- 3 files changed, 14 insertions(+), 16 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..191381e --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.git \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 69b9294..f385c43 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,16 @@ # Docker image for the Drone Terraform plugin # # docker build -t jmccann/drone-terraform:latest . -FROM golang:1.10-alpine AS builder -COPY ./*.go ./src/ -COPY ./vendor/ ./src/ -RUN set -ex \ - && cd ./src \ - && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo -o /go/bin/drone-terraform +FROM golang:1.11-alpine AS builder + +RUN apk add --no-cache git + +RUN mkdir -p /tmp/drone-terraform +WORKDIR /tmp/drone-terraform +COPY . . + +RUN go mod download +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo -o /go/bin/drone-terraform FROM alpine:3.7 diff --git a/README.md b/README.md index b5e4368..54ee29f 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,10 @@ a listing of the available options please take a look at [the docs](https://gith Build the binary with the following commands: ``` -go build +export GO111MODULE=on +go mod download go test +go build ``` ## Docker @@ -19,18 +21,9 @@ go test Build the docker image with the following commands: ``` -CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -tags netgo docker build --rm=true -t jmccann/drone-terraform . ``` -Please note incorrectly building the image for the correct x64 linux and with -GCO disabled will result in an error when running the Docker image: - -``` -docker: Error response from daemon: Container command -'/bin/drone-terraform' not found or does not exist. -``` - ## Usage Execute from the working directory: