From 9a62862cbc209f89a2568857245d839e34340c72 Mon Sep 17 00:00:00 2001 From: Michiel Kalkman Date: Wed, 19 Dec 2018 08:36:47 +1100 Subject: [PATCH 01/12] Add Dockerfile for automated builds Signed-off-by: Michiel Kalkman --- Dockerfile | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9355790 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM golang:1.11-alpine as builder + +# Install our build tools + +RUN apk add --update git make curl bash +RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + +# Get sources + +RUN go get github.com/bloomberg/goldpinger/cmd/goldpinger +WORKDIR /go/src/github.com/bloomberg/goldpinger + +# Install our dependencies + +RUN make vendor + +# Build goldpinger + +RUN make bin/goldpinger + +# Build the asset container, copy over goldpinger + +FROM scratch +COPY --from=builder /go/src/github.com/bloomberg/goldpinger/bin/goldpinger /goldpinger +ENTRYPOINT ["/goldpinger", "--static-file-path", "/static"] + From 4bdda1f6be8e51e755ccf4030ed567bb3b311023 Mon Sep 17 00:00:00 2001 From: Michiel Kalkman Date: Wed, 19 Dec 2018 10:25:02 +1100 Subject: [PATCH 02/12] Remove unnecessary pkg installation, add static - Remove curl installation - Change dep installation from 'curl' to 'go get' - Copy static content to asset container Signed-off-by: Michiel Kalkman --- Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9355790..172d27d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,8 @@ FROM golang:1.11-alpine as builder # Install our build tools -RUN apk add --update git make curl bash -RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh +RUN apk add --update git make +RUN go get -u github.com/golang/dep/cmd/dep # Get sources @@ -16,11 +16,13 @@ RUN make vendor # Build goldpinger +RUN apk add bash RUN make bin/goldpinger # Build the asset container, copy over goldpinger FROM scratch COPY --from=builder /go/src/github.com/bloomberg/goldpinger/bin/goldpinger /goldpinger +COPY ./static /static ENTRYPOINT ["/goldpinger", "--static-file-path", "/static"] From a00da77b2c8769fdba4c77a5f711b23b776f6b81 Mon Sep 17 00:00:00 2001 From: Michiel Kalkman Date: Wed, 19 Dec 2018 21:43:22 +1100 Subject: [PATCH 03/12] Run 'apk add' once for all required packages Signed-off-by: Michiel Kalkman --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 172d27d..7e38d28 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM golang:1.11-alpine as builder # Install our build tools -RUN apk add --update git make +RUN apk add --update git make bash RUN go get -u github.com/golang/dep/cmd/dep # Get sources @@ -16,7 +16,6 @@ RUN make vendor # Build goldpinger -RUN apk add bash RUN make bin/goldpinger # Build the asset container, copy over goldpinger From c294816ae511b5594efb8a557115d5cd132060b8 Mon Sep 17 00:00:00 2001 From: Mikolaj Pawlikowski Date: Wed, 19 Dec 2018 11:53:22 +0000 Subject: [PATCH 04/12] rename the base Dockerfile to Dockerfile-simple Signed-off-by: Mikolaj Pawlikowski --- Makefile | 2 +- build/{Dockerfile => Dockerfile-simple} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename build/{Dockerfile => Dockerfile-simple} (100%) diff --git a/Makefile b/Makefile index cf2aa75..98e6c01 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ swagger: swagger generate client -t pkg -f ./swagger.yml -A goldpinger build: bin/$(bin) - sudo docker build -t $(tag) -f ./build/Dockerfile . + sudo docker build -t $(tag) -f ./build/Dockerfile-simple . tag: sudo docker tag $(tag) $(namespace)$(tag) diff --git a/build/Dockerfile b/build/Dockerfile-simple similarity index 100% rename from build/Dockerfile rename to build/Dockerfile-simple From bdcf179d5fd0b2d1a37c41ba955985dc90a1e7ce Mon Sep 17 00:00:00 2001 From: Mikolaj Pawlikowski Date: Wed, 19 Dec 2018 11:53:33 +0000 Subject: [PATCH 05/12] rename the base Dockerfile to Dockerfile-simple Signed-off-by: Mikolaj Pawlikowski --- Makefile | 3 +++ README.md | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Makefile b/Makefile index 98e6c01..da2c016 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,9 @@ swagger: swagger generate server -t pkg -f ./swagger.yml --exclude-main -A goldpinger && \ swagger generate client -t pkg -f ./swagger.yml -A goldpinger +build-multistage: + sudo docker build -t $(tag) -f ./Dockerfile . + build: bin/$(bin) sudo docker build -t $(tag) -f ./build/Dockerfile-simple . diff --git a/README.md b/README.md index 7d314f1..edca393 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,25 @@ Note, that in order to guarantee correct versions of dependencies, the project [ ## Building +The repo comes with two ways of building a `docker` image: compliling locally, and compliling using a multi-stage `Dockerfile` image. + +### Compiling using a multi-stage `Dockerfile` + +You will need `docker` version 17.05+ installed to support multi-stage builds. + +```sh +# step 1: launch the build +make build-multistage + +# step 2: push the image somewhere +namespace="docker.io/myhandle/" make tag +namespace="docker.io/myhandle/" make push +``` + +This was contributed via @michiel - kudos ! + +### Compliling locally + In order to build `Goldpinger`, you are going to need `go` version 1.10+, `dep`, and `docker`. Building from source code consists of compiling the binary and building a [Docker image](./build/Dockerfile): From 28cc2894ebca1c74a35d06e00d6fb2044a0738e9 Mon Sep 17 00:00:00 2001 From: Mikolaj Pawlikowski Date: Wed, 19 Dec 2018 11:57:09 +0000 Subject: [PATCH 06/12] added the menu, fixed few typos Signed-off-by: Mikolaj Pawlikowski --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index edca393..0cbb373 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ Oh, and it gives you the graph below for your cluster. Check out the [video expl - [Rationale](#rationale) - [Quick start](#quick-start) - [Building](#building) + - [Compiling using a multi-stage Dockerfile](#compiling-using-a-multi-stage-dockerfile) + - [Compililing locally](#compililing-locally) - [Installation](#installation) - [Authentication with Kubernetes API](#authentication-with-kubernetes-api) - [Example YAML](#example-yaml) @@ -48,7 +50,7 @@ Note, that in order to guarantee correct versions of dependencies, the project [ The repo comes with two ways of building a `docker` image: compliling locally, and compliling using a multi-stage `Dockerfile` image. -### Compiling using a multi-stage `Dockerfile` +### Compiling using a multi-stage Dockerfile You will need `docker` version 17.05+ installed to support multi-stage builds. @@ -63,7 +65,7 @@ namespace="docker.io/myhandle/" make push This was contributed via @michiel - kudos ! -### Compliling locally +### Compililing locally In order to build `Goldpinger`, you are going to need `go` version 1.10+, `dep`, and `docker`. From 53c1b0e78ec6231d53bbf4e3ef728bec4ed798c9 Mon Sep 17 00:00:00 2001 From: Mikolaj Pawlikowski Date: Wed, 19 Dec 2018 11:58:15 +0000 Subject: [PATCH 07/12] add link to michiel's profile in readme Signed-off-by: Mikolaj Pawlikowski --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0cbb373..5c98905 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ namespace="docker.io/myhandle/" make tag namespace="docker.io/myhandle/" make push ``` -This was contributed via @michiel - kudos ! +This was contributed via [@michiel](https://github.com/michiel) - kudos ! ### Compililing locally From 6640f0d5c8830284cd9a6879ba33974baa4cb384 Mon Sep 17 00:00:00 2001 From: Mikolaj Pawlikowski Date: Wed, 19 Dec 2018 12:00:14 +0000 Subject: [PATCH 08/12] more typos Signed-off-by: Mikolaj Pawlikowski --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5c98905..1c18588 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Oh, and it gives you the graph below for your cluster. Check out the [video expl - [Quick start](#quick-start) - [Building](#building) - [Compiling using a multi-stage Dockerfile](#compiling-using-a-multi-stage-dockerfile) - - [Compililing locally](#compililing-locally) + - [Compiling locally](#compiling-locally) - [Installation](#installation) - [Authentication with Kubernetes API](#authentication-with-kubernetes-api) - [Example YAML](#example-yaml) @@ -65,7 +65,7 @@ namespace="docker.io/myhandle/" make push This was contributed via [@michiel](https://github.com/michiel) - kudos ! -### Compililing locally +### Compiling locally In order to build `Goldpinger`, you are going to need `go` version 1.10+, `dep`, and `docker`. From 8f738e70a79589c7c3e41ec77afafc6a30b15b86 Mon Sep 17 00:00:00 2001 From: Mikolaj Pawlikowski Date: Wed, 19 Dec 2018 12:05:10 +0000 Subject: [PATCH 09/12] fix the reference to the Dockerfile in the buld folder Signed-off-by: Mikolaj Pawlikowski --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c18588..e877ae3 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ This was contributed via [@michiel](https://github.com/michiel) - kudos ! In order to build `Goldpinger`, you are going to need `go` version 1.10+, `dep`, and `docker`. -Building from source code consists of compiling the binary and building a [Docker image](./build/Dockerfile): +Building from source code consists of compiling the binary and building a [Docker image](./build/Dockerfile-simple): ```sh # step 0: check out the code into your $GOPATH From 758cc2bcd6f437e8b23ca92d088ee0f0670375fc Mon Sep 17 00:00:00 2001 From: Mikolaj Pawlikowski Date: Wed, 19 Dec 2018 12:12:00 +0000 Subject: [PATCH 10/12] use docker service in travis, and build both the simple and the multistage dockerfiles Signed-off-by: Mikolaj Pawlikowski --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index eeac097..6e62dad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,12 @@ language: go +services: + - docker + go: - "1.10.x" - master -script: go get -u github.com/golang/dep/cmd/dep && make vendor && make +script: + - go get -u github.com/golang/dep/cmd/dep && make vendor && make && make build + - make build-multistage From d0ad01c06e2764ad77ddb10556c35571e583f349 Mon Sep 17 00:00:00 2001 From: Mikolaj Pawlikowski Date: Wed, 19 Dec 2018 12:13:43 +0000 Subject: [PATCH 11/12] also print the docker version Signed-off-by: Mikolaj Pawlikowski --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6e62dad..2d3d936 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,5 +8,6 @@ go: - master script: + - docker --version - go get -u github.com/golang/dep/cmd/dep && make vendor && make && make build - make build-multistage From 6bc695b77134cbbb214af938851ae0df85f1a1e4 Mon Sep 17 00:00:00 2001 From: Mikolaj Pawlikowski Date: Wed, 19 Dec 2018 12:21:25 +0000 Subject: [PATCH 12/12] print the images built in the meantime Signed-off-by: Mikolaj Pawlikowski --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2d3d936..becc47f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,6 @@ go: script: - docker --version - go get -u github.com/golang/dep/cmd/dep && make vendor && make && make build + - docker images - make build-multistage + - docker images