From 99bc83db4bdc9cf783ce4d9e34bef7404376db36 Mon Sep 17 00:00:00 2001 From: Stephane Erbrech Date: Tue, 5 Dec 2017 11:55:15 +0100 Subject: [PATCH 1/3] add Dockerfile and tiny build scripts --- Dockerfile | 13 +++++++++++++ build.ps1 | 1 + build.sh | 2 ++ 3 files changed, 16 insertions(+) create mode 100644 Dockerfile create mode 100644 build.ps1 create mode 100644 build.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c1065d9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +# build stage +FROM ataraev/golang-alpine-git AS build-env +ADD . /go/app +WORKDIR /go/app +ENV GOBIN /go/bin +RUN go get -d -v ./ +RUN go build -o traefik-appinsight-watchdog -v + +# final stage +FROM golang:alpine +WORKDIR /app +COPY --from=build-env /go/app/traefik-appinsight-watchdog . +ENTRYPOINT ./traefik-appinsight-watchdog \ No newline at end of file diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..b70c762 --- /dev/null +++ b/build.ps1 @@ -0,0 +1 @@ +docker build . -t traefik-appinsights-watchdog \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..a3cb169 --- /dev/null +++ b/build.sh @@ -0,0 +1,2 @@ +#/bin/sh +docker build . -t traefik-appinsights-watchdog \ No newline at end of file From e428154723d75b07503c941be24ce0271ba5f8b6 Mon Sep 17 00:00:00 2001 From: Stephane Erbrech Date: Tue, 5 Dec 2017 12:37:21 +0100 Subject: [PATCH 2/3] make container accept parameters following run --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index c1065d9..33b2f0a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,10 +4,10 @@ ADD . /go/app WORKDIR /go/app ENV GOBIN /go/bin RUN go get -d -v ./ -RUN go build -o traefik-appinsight-watchdog -v +RUN go build -o traefik-appinsights-watchdog -v # final stage FROM golang:alpine WORKDIR /app -COPY --from=build-env /go/app/traefik-appinsight-watchdog . -ENTRYPOINT ./traefik-appinsight-watchdog \ No newline at end of file +COPY --from=build-env /go/app/traefik-appinsights-watchdog . +ENTRYPOINT ["./traefik-appinsights-watchdog"] \ No newline at end of file From 2a8a66dce5933969b9a51d7314ce7e697af78b37 Mon Sep 17 00:00:00 2001 From: Stephane Erbrech Date: Tue, 5 Dec 2017 17:42:31 +0100 Subject: [PATCH 3/3] use dep to resolve dependencies and cache the vendor libs --- .dockerignore | 1 + Dockerfile | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..5657f6e --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +vendor \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 33b2f0a..6619973 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,19 @@ # build stage FROM ataraev/golang-alpine-git AS build-env -ADD . /go/app -WORKDIR /go/app ENV GOBIN /go/bin -RUN go get -d -v ./ +RUN apk add --update openssl && \ + wget -O /go/bin/dep http://github.com/golang/dep/releases/download/v0.3.2/dep-linux-amd64 && \ + chmod +x /go/bin/dep + +COPY ./Gopkg.* /go/src/github.com/lawrencegripper/traefik-appinsights-watchdog/ +WORKDIR /go/src/github.com/lawrencegripper/traefik-appinsights-watchdog +RUN dep ensure --vendor-only -v + +COPY . /go/src/github.com/lawrencegripper/traefik-appinsights-watchdog/ RUN go build -o traefik-appinsights-watchdog -v # final stage FROM golang:alpine WORKDIR /app -COPY --from=build-env /go/app/traefik-appinsights-watchdog . +COPY --from=build-env /go/src/github.com/lawrencegripper/traefik-appinsights-watchdog/traefik-appinsights-watchdog . ENTRYPOINT ["./traefik-appinsights-watchdog"] \ No newline at end of file