diff --git a/build.armhf.sh b/build.armhf.sh new file mode 100755 index 0000000000000000000000000000000000000000..44fdce64be11db1aadcff96ee52affc3edd6120c --- /dev/null +++ b/build.armhf.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +(cd gateway && ./armhf.build.sh) +(cd watchdog && ./armhf.build.sh) diff --git a/deploy_stack.sh b/deploy_stack.sh index a900d6d5c75bcce423e10528767f07bb38e67f18..ff8187f98b7c9b8b0e1c04b509275372280d813e 100755 --- a/deploy_stack.sh +++ b/deploy_stack.sh @@ -1,4 +1,5 @@ #!/bin/sh echo "Deploying stack" -docker stack deploy func --compose-file docker-compose.yml +docker stack deploy func --compose-file docker-compose.yml + diff --git a/deploy_stack_arm.sh b/deploy_stack_arm.sh new file mode 100755 index 0000000000000000000000000000000000000000..e9fcdedb71f6220e444f4a79526ac0f789df4ff8 --- /dev/null +++ b/deploy_stack_arm.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "Deploying stack" +docker stack deploy func --compose-file docker-compose.armhf.yml diff --git a/docker-compose.armhf.yml b/docker-compose.armhf.yml new file mode 100644 index 0000000000000000000000000000000000000000..ff01f62fbe288ad08ad58a8a2341e21e13fd4d29 --- /dev/null +++ b/docker-compose.armhf.yml @@ -0,0 +1,103 @@ +version: "3" +services: + +# Core API services are pinned, HA is provided for functions. + gateway: + volumes: + - "/var/run/docker.sock:/var/run/docker.sock" + ports: + - 8080:8080 + image: alexellis2/faas-gateway:latest-armhf + networks: + - functions + deploy: + placement: + constraints: [node.role == manager] + + prometheus: + image: alexellis2/prometheus-armhf:latest + volumes: + - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml + - ./prometheus/alert.rules:/etc/prometheus/alert.rules + + command: "-config.file=/etc/prometheus/prometheus.yml -storage.local.path=/prometheus -storage.local.memory-chunks=10000 --alertmanager.url=http://alertmanager:9093" + ports: + - 9090:9090 + depends_on: + - gateway + - alertmanager + environment: + no_proxy: "gateway" + networks: + - functions + deploy: + placement: + constraints: [node.role == manager] + + + alertmanager: + image: alexellis2/alertmanager-armhf + environment: + no_proxy: "gateway" + volumes: + - ./prometheus/alertmanager.yml:/alertmanager.yml + command: + - '-config.file=/alertmanager.yml' + networks: + - functions + ports: + - 9093:9093 + deploy: + placement: + constraints: [node.role == manager] + +# Sample functions go here. + wordcount: + image: alexellis2/faas-alpinefunction:latest-armhf + depends_on: + - gateway + networks: + - functions + environment: + fprocess: "wc" + no_proxy: "gateway" + https_proxy: $https_proxy + + + + echoit: + image: alexellis2/faas-alpinefunction:latest-armhf + depends_on: + - gateway + networks: + - functions + environment: + fprocess: "cat" + no_proxy: "gateway" + https_proxy: $https_proxy + + nodeinfo: + image: alexellis2/faas-nodeinfo:latest-armhf + depends_on: + - gateway + networks: + - functions + environment: + no_proxy: "gateway" + https_proxy: $https_proxy + + hubstats: + image: alexellis2/faas-hubstats:latest-armhf + depends_on: + - gateway + networks: + - functions + environment: + no_proxy: "gateway" + https_proxy: $https_proxy + +networks: + functions: + driver: overlay + # Docker does not support this option yet - maybe create outside of the stack and reference as "external"? + #attachable: true diff --git a/gateway/Dockerfile.build.armhf b/gateway/Dockerfile.build.armhf index 3a8914988b7fd36eeded535ae5f3bb67638fbcc4..6d593d051a0860535cfffa662780a7ff57e8f5fd 100644 --- a/gateway/Dockerfile.build.armhf +++ b/gateway/Dockerfile.build.armhf @@ -6,11 +6,15 @@ RUN go get -d github.com/docker/docker/api/types \ && go get -d github.com/docker/docker/client \ && go get github.com/gorilla/mux \ && go get github.com/prometheus/client_golang/prometheus +RUN go get -d github.com/Sirupsen/logrus WORKDIR /go/src/github.com/alexellis/faas/gateway -COPY metrics metrics -COPY server.go . +COPY metrics metrics +COPY requests requests +COPY tests tests +COPY handlers handlers + +COPY server.go . -RUN find /go/src/github.com/alexellis/faas/gateway/ RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . diff --git a/sample-functions/AlpineFunction/Dockerfile.armhf b/sample-functions/AlpineFunction/Dockerfile.armhf new file mode 100644 index 0000000000000000000000000000000000000000..0d01a4297f3373d6422d8839effc4d5cafba77d4 --- /dev/null +++ b/sample-functions/AlpineFunction/Dockerfile.armhf @@ -0,0 +1,8 @@ +FROM armhf/alpine:latest + +COPY fwatchdog /usr/bin +RUN chmod +x /usr/bin/fwatchdog + +# Populate example here +# ENV fprocess="wc -l" +CMD ["fwatchdog"] diff --git a/sample-functions/AlpineFunction/build.armhf.sh b/sample-functions/AlpineFunction/build.armhf.sh new file mode 100755 index 0000000000000000000000000000000000000000..465ce33009a2645b7f4ecbaefa7f67aba81ea9d5 --- /dev/null +++ b/sample-functions/AlpineFunction/build.armhf.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker build -f Dockerfile.armhf -t alexellis2/faas-alpinefunction:latest-armhf . diff --git a/sample-functions/DockerHubStats/Dockerfile.armhf b/sample-functions/DockerHubStats/Dockerfile.armhf new file mode 100644 index 0000000000000000000000000000000000000000..dc09f95317086aac02dd6083c3a3c19a24d768d3 --- /dev/null +++ b/sample-functions/DockerHubStats/Dockerfile.armhf @@ -0,0 +1,17 @@ +FROM alexellis2/go-armhf:1.7.4 + +MAINTAINER alexellis2@gmail.com +ENTRYPOINT [] + +RUN apk --no-cache add make +WORKDIR /go/src/github.com/alexellis/faas/sample-functions/DockerHubStats +COPY . /go/src/github.com/alexellis/faas/sample-functions/DockerHubStats + +RUN make + +COPY ./fwatchdog /usr/bin +RUN chmod +x /usr/bin/fwatchdog + +ENV fprocess "/go/bin/DockerHubStats" + +CMD [ "/usr/bin/fwatchdog"] diff --git a/sample-functions/DockerHubStats/build.armhf.sh b/sample-functions/DockerHubStats/build.armhf.sh new file mode 100755 index 0000000000000000000000000000000000000000..b04a94d34dfac8ca000c45c59528384a84dce691 --- /dev/null +++ b/sample-functions/DockerHubStats/build.armhf.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker build -t alexellis2/faas-hubstats:latest-armhf . diff --git a/sample-functions/NodeInfo/Dockerfile.armhf b/sample-functions/NodeInfo/Dockerfile.armhf new file mode 100644 index 0000000000000000000000000000000000000000..852804cb35c631bca112cd46310e20627f8bb25a --- /dev/null +++ b/sample-functions/NodeInfo/Dockerfile.armhf @@ -0,0 +1,12 @@ +FROM armhf/alpine:latest +RUN apk --update add nodejs + +COPY fwatchdog /usr/bin + +RUN chmod +x /usr/bin/fwatchdog + +COPY package.json . +COPY main.js . +RUN npm i +ENV fprocess="node main.js" +CMD ["fwatchdog"] diff --git a/sample-functions/NodeInfo/build.armhf.sh b/sample-functions/NodeInfo/build.armhf.sh new file mode 100755 index 0000000000000000000000000000000000000000..eab925f049482633ff0eee42850f95362275f33d --- /dev/null +++ b/sample-functions/NodeInfo/build.armhf.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +docker build -f Dockerfile.armhf -t alexellis2/faas-nodeinfo:latest-armhf . diff --git a/watchdog/Dockerfile.armhf b/watchdog/Dockerfile.armhf index 9b3478db258485c844f6c0d2d92dcbd5d7c02e7a..cc9a25022a36190e9b35eef9cd8c949d0e747caf 100644 --- a/watchdog/Dockerfile.armhf +++ b/watchdog/Dockerfile.armhf @@ -1,7 +1,12 @@ FROM alexellis2/go-armhf:1.7.4 - RUN mkdir -p /go/src/app -COPY main.go /go/src/app +WORKDIR /go/src/app +COPY main.go . +COPY readconfig.go . +COPY config_test.go . + WORKDIR /go/src/app RUN go get -d -v + +RUN go test RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .