From ee95e272cc16be1bfed1a7ec27f7628ecdcd3b6f Mon Sep 17 00:00:00 2001 From: Alex Ellis Date: Thu, 13 Apr 2017 22:58:32 +0100 Subject: [PATCH] Make webhookstash a static binary --- contrib/dind/test.sh | 6 +++--- docker-compose.yml | 3 +-- sample-functions/WebhookStash/.gitignore | 1 + sample-functions/WebhookStash/Dockerfile | 17 +++++++++-------- sample-functions/WebhookStash/Dockerfile.build | 9 +++++++++ sample-functions/WebhookStash/build.sh | 11 +++++++++-- 6 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 sample-functions/WebhookStash/.gitignore create mode 100644 sample-functions/WebhookStash/Dockerfile.build diff --git a/contrib/dind/test.sh b/contrib/dind/test.sh index 1e724d73..722f44f6 100755 --- a/contrib/dind/test.sh +++ b/contrib/dind/test.sh @@ -21,7 +21,7 @@ echo function test_function_output { for i in {1..100} do - out=$(curl -s localhost:8080/function/$1 -d "$2") + out=$(curl --fail -s localhost:8080/function/$1 -d "$2") echo $out if [ "$out" == "$3" ] then @@ -41,7 +41,7 @@ echo function test_function { for i in {1..100} do - curl localhost:8080/function/$1 -d "$2" + curl -s --fail localhost:8080/function/$1 -d "$2" if [ ! 0 -eq $? ] then echo "Service $1 not ready" @@ -58,7 +58,7 @@ echo function create_function { echo "Creating function: " $1 - curl -s localhost:8080/system/functions -d "$1" + curl -s --fail localhost:8080/system/functions -d "$1" } test_gateway diff --git a/docker-compose.yml b/docker-compose.yml index 814c1bae..a39c7ee4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,7 +34,6 @@ services: placement: constraints: [node.role == manager] - alertmanager: image: quay.io/prometheus/alertmanager environment: @@ -55,7 +54,7 @@ services: # Service label of "function" allows functions to show up in UI on http://gateway:8080/ webhookstash: - image: alexellis2/faas-webhookstash:latest + image: functions/webhookstash:latest labels: function: "true" depends_on: diff --git a/sample-functions/WebhookStash/.gitignore b/sample-functions/WebhookStash/.gitignore new file mode 100644 index 00000000..b80f0bd6 --- /dev/null +++ b/sample-functions/WebhookStash/.gitignore @@ -0,0 +1 @@ +app diff --git a/sample-functions/WebhookStash/Dockerfile b/sample-functions/WebhookStash/Dockerfile index b34e38c4..8159a82b 100644 --- a/sample-functions/WebhookStash/Dockerfile +++ b/sample-functions/WebhookStash/Dockerfile @@ -1,15 +1,16 @@ -FROM golang:1.7.5 -RUN mkdir -p /go/src/app -COPY handler.go /go/src/app -WORKDIR /go/src/app -RUN go get -d -v -RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . +FROM alpine:latest +WORKDIR /root/ -ADD https://github.com/alexellis/faas/releases/download/0.5.1-alpha/fwatchdog /usr/bin +EXPOSE 8080 +ENV http_proxy "" +ENV https_proxy "" +ADD https://github.com/alexellis/faas/releases/download/v0.5-alpha/fwatchdog /usr/bin RUN chmod +x /usr/bin/fwatchdog # COPY fwatchdog /usr/bin/ -ENV fprocess="/go/src/app/app" +COPY app . + +ENV fprocess="/root/app" CMD ["fwatchdog"] diff --git a/sample-functions/WebhookStash/Dockerfile.build b/sample-functions/WebhookStash/Dockerfile.build new file mode 100644 index 00000000..8864a954 --- /dev/null +++ b/sample-functions/WebhookStash/Dockerfile.build @@ -0,0 +1,9 @@ +FROM golang:1.7.5 + +RUN mkdir -p /go/src/app +COPY handler.go /go/src/app +WORKDIR /go/src/app +RUN go get -d -v +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . + +CMD ["/bin/true"] diff --git a/sample-functions/WebhookStash/build.sh b/sample-functions/WebhookStash/build.sh index e7cda971..dcc6befe 100755 --- a/sample-functions/WebhookStash/build.sh +++ b/sample-functions/WebhookStash/build.sh @@ -1,3 +1,10 @@ -#!/bin/bash +#!/bin/sh +echo Building functions/webhookstash:build -docker build -t alexellis2/faas-webhookstash . +docker build --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -t functions/webhookstash:build . -f Dockerfile.build && \ + docker create --name hook_extract functions/webhookstash:build +docker cp hook_extract:/go/src/app/app ./app +docker rm -f hook_extract + +echo Building functions/webhookstash:latest +docker build --no-cache -t functions/webhookstash:latest .