From a72f1e9bd5471724dd7fd667aa9f7a9dd56992a5 Mon Sep 17 00:00:00 2001 From: Elliott Spira Date: Thu, 20 Jul 2017 11:01:28 +1000 Subject: [PATCH 1/5] adding Dockerfile, such that this project can run as a container --- Dockerfile | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..64d37392 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM golang:1.8 + +WORKDIR /go/src/app +COPY . . + +RUN go-wrapper download # "go get -d -v ./..." +RUN go-wrapper install # "go install -v ./..." +RUN go build + +CMD ["go-wrapper", "run"] # ["app"] From a32f896da99d9988f7f63202be0b9a6ffc5fafc9 Mon Sep 17 00:00:00 2001 From: Elliott Spira Date: Thu, 20 Jul 2017 13:21:08 +1000 Subject: [PATCH 2/5] adding arguments environment variable to contain any command line arguments for the aws-es-proxy command --- Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 64d37392..2e52fa76 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,12 @@ FROM golang:1.8 +ENV arguments + WORKDIR /go/src/app COPY . . -RUN go-wrapper download # "go get -d -v ./..." -RUN go-wrapper install # "go install -v ./..." +RUN go-wrapper download +RUN go-wrapper install RUN go build -CMD ["go-wrapper", "run"] # ["app"] +CMD ["go-wrapper", "run", "${arguments}"] From 006ca76344f0897da67d1ef3b969622f8a5d8dd0 Mon Sep 17 00:00:00 2001 From: Elliott Spira Date: Thu, 20 Jul 2017 13:59:22 +1000 Subject: [PATCH 3/5] adding README. fixing var substitution in CMD for Dockerfile --- Dockerfile | 4 ++-- README.md | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2e52fa76..1d89b3b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM golang:1.8 -ENV arguments +ENV arguments "-h" WORKDIR /go/src/app COPY . . @@ -9,4 +9,4 @@ RUN go-wrapper download RUN go-wrapper install RUN go build -CMD ["go-wrapper", "run", "${arguments}"] +CMD go-wrapper run ${arguments} diff --git a/README.md b/README.md index 1d233419..69eeea9e 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,18 @@ Usage of ./aws-es-proxy: Print user requests ``` +## Docker + +There is a docker image avaiable for aws-es-proxy. There is an image on docker hub called `gorillastack/aws-es-proxy`. Supply command line arguments by passing an environment variable called `arguments`. + +To run the image: + +```sh +docker run --rm -e arguments="-endpoint https://dummy-host.ap-southeast-2.es.amazonaws.com" -i gorillastack/aws-es-proxy +``` + +If no arguments environment variable is set, -h will be used by default, printing the usage. + ## Using HTTP Clients After you run *aws-es-proxy*, you can now open your Web browser on [http://localhost:9200](http://localhost:9200). Everything should be working as you have your own instance of ElasticSearch running on port 9200. From 1c6a11d97ef8e51cd6b99133c455c8161638d1ac Mon Sep 17 00:00:00 2001 From: Elliott Spira Date: Thu, 20 Jul 2017 16:39:43 +1000 Subject: [PATCH 4/5] simplifying launch mechanism --- Dockerfile | 6 ++---- README.md | 12 ++++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1d89b3b1..c639bbbd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,10 @@ FROM golang:1.8 -ENV arguments "-h" - WORKDIR /go/src/app COPY . . RUN go-wrapper download RUN go-wrapper install -RUN go build +RUN go build -o aws-es-proxy -CMD go-wrapper run ${arguments} +CMD ["./aws-es-proxy", "-h"] diff --git a/README.md b/README.md index 69eeea9e..5780aa55 100644 --- a/README.md +++ b/README.md @@ -109,15 +109,15 @@ Usage of ./aws-es-proxy: ## Docker -There is a docker image avaiable for aws-es-proxy. There is an image on docker hub called `gorillastack/aws-es-proxy`. Supply command line arguments by passing an environment variable called `arguments`. - -To run the image: +There is a docker image avaiable for aws-es-proxy. There is an image on docker hub called `gorillastack/aws-es-proxy`. To run the image: ```sh -docker run --rm -e arguments="-endpoint https://dummy-host.ap-southeast-2.es.amazonaws.com" -i gorillastack/aws-es-proxy -``` +# Prints usage info (-h) +docker run --rm -it gorillastack/aws-es-proxy -If no arguments environment variable is set, -h will be used by default, printing the usage. +# Runs with custom command/args +docker run --rm -it gorillastack/aws-es-proxy ./aws-es-proxy -endpoint https://dummy-host.ap-southeast-2.es.amazonaws.com +``` ## Using HTTP Clients From 004b7184a2bdcbf7f594940425c389809b249e9e Mon Sep 17 00:00:00 2001 From: Elliott Spira Date: Mon, 24 Jul 2017 12:49:57 +1000 Subject: [PATCH 5/5] forgot to expose a port number in the dockerfile. adding comment in README to instruct about use of the PORT_NUM environment variable to customise the exposed port --- Dockerfile | 3 +++ README.md | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index c639bbbd..64c07b62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ FROM golang:1.8 +ENV PORT_NUM 9200 WORKDIR /go/src/app COPY . . @@ -7,4 +8,6 @@ RUN go-wrapper download RUN go-wrapper install RUN go build -o aws-es-proxy +EXPOSE ${PORT_NUM} + CMD ["./aws-es-proxy", "-h"] diff --git a/README.md b/README.md index 5780aa55..9ee02f41 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,8 @@ docker run --rm -it gorillastack/aws-es-proxy docker run --rm -it gorillastack/aws-es-proxy ./aws-es-proxy -endpoint https://dummy-host.ap-southeast-2.es.amazonaws.com ``` +To expose a port number other than the default 9200, pass an environment variable of `PORT_NUM` to docker with the port number you wish to expose for your service. + ## Using HTTP Clients After you run *aws-es-proxy*, you can now open your Web browser on [http://localhost:9200](http://localhost:9200). Everything should be working as you have your own instance of ElasticSearch running on port 9200.