Skip to content

Instantly share code, notes, and snippets.

@zeerorg
Last active November 1, 2019 12:41
Show Gist options
  • Save zeerorg/caf250a9cd277629d01e3b06ee078e19 to your computer and use it in GitHub Desktop.
Save zeerorg/caf250a9cd277629d01e3b06ee078e19 to your computer and use it in GitHub Desktop.
diff --git a/git-tar/Dockerfile b/git-tar/Dockerfile
index 2012ff1..c17cfea 100644
--- a/git-tar/Dockerfile
+++ b/git-tar/Dockerfile
@@ -2,8 +2,8 @@ FROM golang:1.10.4-alpine3.7 as build
RUN apk --no-cache add curl \
&& echo "Pulling watchdog binary from GitHub." \
- && curl -sSL https://github.com/openfaas/faas/releases/download/0.9.5/fwatchdog > /usr/bin/fwatchdog \
- && curl -sSL https://github.com/openfaas/faas-cli/releases/download/0.7.3/faas-cli > /usr/local/bin/faas-cli \
+ && curl -sSL https://github.com/openfaas/faas/releases/download/0.9.5/fwatchdog-armhf > /usr/bin/fwatchdog \
+ && curl -sSL https://github.com/openfaas/faas-cli/releases/download/0.7.3/faas-cli-armhf > /usr/local/bin/faas-cli \
&& chmod +x /usr/bin/fwatchdog \
&& chmod +x /usr/local/bin/faas-cli \
&& apk del curl --no-cache

Deploying openfaas cloud on armhf

Prerequisites

  1. A domain name which can point to your deployment. (subdomain names also work)
  2. Setup Github app. Refer this. You'll need to transfer the downloaded private-key.pem file to arm device.
  3. Docker hub account.

Core components steps:

  1. Sign in to docker hub on your machine using:
DOCKER_USERNAME=(enter your docker username)
DOCKER_PASSWORD=(enter your docker password)
docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD
  1. You'll need to set 'registry-secret' and 'payload-secret' using command
cat $HOME/.docker/config.json | docker secret create registry-secret -

PAYLOAD_SECRET=$(head -c 12 /dev/urandom | shasum| cut -d' ' -f1)
echo -n "$PAYLOAD_SECRET" | docker secret create payload-secret -
  1. Run buildkit and of-builder with
docker rm -f of-buildkit
docker run -d --net func_functions -d --privileged \
--restart always \
--name of-buildkit moby/buildkit:v0.3.3 --addr tcp://0.0.0.0:1234

docker service create --constraint="node.role==manager" \
 --name of-builder \
 --env insecure=false --detach=true --network func_functions \
 --secret src=registry-secret,target="/home/app/.docker/config.json" \
 --secret src=payload-secret,target="/var/openfaas/secrets/payload-secret" \
 --env enable_lchown=false \
zeerorg/of-builder:armhf
  1. Setup Github app secrets
WEBHOOK_SECRET="Long-Password-Phrase-Goes-Here"
echo -n "$WEBHOOK_SECRET" | docker secret create github-webhook-secret -

docker secret create private-key "location of private-key.pem"
  1. Deploy minio using:
SECRET_KEY=$(head -c 12 /dev/urandom | shasum| cut -d' ' -f1)
ACCESS_KEY=$(head -c 12 /dev/urandom | shasum| cut -d' ' -f1)
docker service rm minio

docker service create --constraint="node.role==manager" \
 --name minio \
 --detach=true --network func_functions \
 --secret s3-access-key \
 --secret s3-secret-key \
 --env MINIO_SECRET_KEY_FILE=s3-secret-key \
 --env MINIO_ACCESS_KEY_FILE=s3-access-key \
zeerorg/minio-armhf:latest server /export
  1. Change gateway_config.yml and remove all occurences of .openfaas (standard step for docker swarm)

  2. faas-cli deploy -f stack.armhf.yml and you should be good to go

provider:
name: faas
gateway: http://127.0.0.1:8080
functions:
system-github-event:
lang: go-armhf
handler: ./github-event
image: zeerorg/github-event:armhf
labels:
openfaas-cloud: "1"
role: openfaas-system
environment:
validate_hmac: true
write_debug: true
read_debug: true
validate_customers: true
environment_file:
- github.yml
- gateway_config.yml
secrets:
- github-webhook-secret
- payload-secret
github-push:
lang: go-armhf
handler: ./github-push
image: zeerorg/github-push:armhf
labels:
openfaas-cloud: "1"
role: openfaas-system
environment:
validate_hmac: true
read_timeout: 10s
write_timeout: 10s
write_debug: true
read_debug: true
environment_file:
- gateway_config.yml
- github.yml
secrets:
- github-webhook-secret
- payload-secret
git-tar:
lang: dockerfile
handler: ./git-tar
image: zeerorg/of-git-tar:armhf
labels:
openfaas-cloud: "1"
role: openfaas-system
environment:
read_timeout: 15m
write_timeout: 15m
write_debug: true
read_debug: true
environment_file:
- gateway_config.yml
- github.yml
secrets:
- payload-secret
- private-key
# Uncomment this for GitLab
# - gitlab-api-token
buildshiprun:
lang: go-armhf
handler: ./buildshiprun
image: zeerorg/of-buildshiprun:armhf
labels:
openfaas-cloud: "1"
role: openfaas-system
environment:
read_timeout: 5m
write_timeout: 5m
write_debug: true
read_debug: true
scaling_factor: 50
environment_file:
- buildshiprun_limits.yml
- gateway_config.yml
- github.yml
secrets:
- basic-auth-user
- basic-auth-password
- payload-secret
# - swarm-pull-secret
garbage-collect:
lang: go-armhf
handler: ./garbage-collect
image: zeerorg/garbage-collect:armhf
labels:
openfaas-cloud: "1"
role: openfaas-system
environment:
write_debug: true
read_debug: true
read_timeout: 30s
write_timeout: 30s
environment_file:
- gateway_config.yml
secrets:
- basic-auth-user
- basic-auth-password
- payload-secret
github-status:
lang: go-armhf
handler: ./github-status
image: zeerorg/github-status:armhf
labels:
openfaas-cloud: "1"
role: openfaas-system
environment:
write_debug: true
read_debug: true
combine_output: false
validate_hmac: true
debug_token: true
environment_file:
- gateway_config.yml
- github.yml
secrets:
- private-key
- payload-secret
import-secrets:
lang: go-armhf
handler: ./import-secrets
image: zeerorg/import-secrets:armhf
labels:
openfaas-cloud: "1"
role: openfaas-system
environment:
write_debug: true
read_debug: true
validate_hmac: true
combined_output: false
environment_file:
- github.yml
secrets:
- payload-secret
pipeline-log:
lang: go-armhf
handler: ./pipeline-log
image: zeerorg/pipeline-log:armhf
labels:
openfaas-cloud: "1"
role: openfaas-system
environment:
write_debug: true
read_debug: true
combine_output: false
environment_file:
- gateway_config.yml
secrets:
- s3-access-key
- s3-secret-key
- payload-secret
list-functions:
lang: go-armhf
handler: ./list-functions
image: zeerorg/list-functions:armhf
labels:
openfaas-cloud: "1"
role: openfaas-system
environment:
write_debug: true
read_debug: true
environment_file:
- gateway_config.yml
secrets:
- basic-auth-user
- basic-auth-password
audit-event:
lang: go-armhf
handler: ./audit-event
image: zeerorg/audit-event:armhf
labels:
openfaas-cloud: "1"
environment_file:
- slack.yml
echo:
skip_build: true
image: functions/alpine:latest
fprocess: cat
environment:
write_debug: true
read_debug: true
system-metrics:
lang: go-armhf
handler: ./system-metrics
image: zeerorg/system-metrics:armhf
environment_file:
- gateway_config.yml
environment:
content_type: "application/json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment