Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

Commit

Permalink
Improve the build process and fix a couple of bugs (#21)
Browse files Browse the repository at this point in the history
* Update faas.hcl

* Reduce size of ephermerial disk for jobs

* Updated OpenFaaS Version

* Updated ephemerial disk size

* Added goreleaser

Update gitignore to remove distribution

Added Arm7 docker image

Added remove dist option for go-releaser

Added manifest for multiarch images

Updated dockerfile

Updated tags

Added goreleaser and arm builds

* Updated travis to add login to registry

* Fixed env vars

* Testing build process with latest docker images

* Switch to local docker registry

* Added version number using ldflags

* Added travis latest group to build

* fix .travis.yml
  • Loading branch information
nicholasjackson committed Jan 16, 2018
1 parent d36ca75 commit d60a081
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .goreleaser.yml
@@ -1,5 +1,6 @@
builds:
- binary: faas-nomad
ldflags: -s -w -X main.version={{.Version}}
goos:
- windows
- linux
Expand Down Expand Up @@ -27,5 +28,5 @@ dockers:
goos: linux
goarch: arm
goarm: 7
dockerfile: Dockerfile
dockerfile: Dockerfile_arm7
tag_template: "arm7-{{ .Tag }}"
15 changes: 9 additions & 6 deletions .travis.yml
@@ -1,3 +1,6 @@
group: travis_latest
sudo: required

language: go

services:
Expand All @@ -14,32 +17,32 @@ env:
before_install:
- sudo apt-get update
- sudo apt-get install unzip curl
- curl https://releases.hashicorp.com/nomad/0.7.0/nomad_0.7.0_linux_amd64.zip -o nomad.zip
- curl https://releases.hashicorp.com/nomad/0.7.1/nomad_0.7.1_linux_amd64.zip -o nomad.zip
- curl https://releases.hashicorp.com/consul/1.0.0/consul_1.0.0_linux_amd64.zip -o consul.zip
- sudo unzip -o -d /usr/local/bin ./nomad.zip
- sudo unzip -o -d /usr/local/bin ./consul.zip
- sudo chmod +x /usr/local/bin/consul
- sudo chmod +x /usr/local/bin/nomad
- make deps
- git clone -b additions https://github.com/nicholasjackson/certify-incubator.git $GOPATH/src/github.com/openfaas/certify-incubator
- docker run -d -p 5000:5000 --restart=always --name registry registry:2

script:
- echo "Build and Test"
- make test
- make build_all
- docker tag quay.io/nicholasjackson/faas-nomad:latest localhost:5000/faas-nomad:latest
- docker push localhost:5000/faas-nomad:latest
- echo "Run Functional Tests"
- source ./startNomad.sh
- nomad run nomad_job_files/faas.hcl
- nomad run nomad_job_files/faas_travis.hcl || true
- sleep 10
- nomad status faas-nomadd
- nomad logs -job faas-nomadd nomadd
- docker ps
- cd $GOPATH/src/github.com/openfaas/certify-incubator && gateway_url=$FAAS_GATEWAY
go test ./tests -v
- nomad status
- cat $HOME/log/nomad.log
- cat $HOME/log/consul.log
- ps -aux | grep nomad
- ps -aux | grep consul

after_success:
if ([ "$TRAVIS_BRANCH" == "master" ] || [ ! -z "$TRAVIS_TAG" ]) &&
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile_arm7
@@ -1,8 +1,8 @@
FROM arm32v6/alpine
FROM alpine:latest

RUN adduser -h /home/faasnomad -D faasnomad faasnomad

COPY ./dist/linuxarm7/faas-nomad /home/faasnomad/
COPY faas-nomad /home/faasnomad/
RUN chmod +x /home/faasnomad/faas-nomad

USER faasnomad
Expand Down
2 changes: 1 addition & 1 deletion main.go
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/openfaas/faas-provider/types"
)

const version = "0.2.16"
var version = "notset"

func setupLogging() hclog.Logger {
logJSON := false
Expand Down
2 changes: 1 addition & 1 deletion nomad_job_files/faas.hcl
Expand Up @@ -72,7 +72,7 @@ EOH
}

config {
image = "nicholasjackson/gateway:latest-dev"
image = "functions/gateway:0.6.14"

port_map {
http = 8080
Expand Down
145 changes: 145 additions & 0 deletions nomad_job_files/faas_travis.hcl
@@ -0,0 +1,145 @@
job "faas-nomadd" {
datacenters = ["dc1"]

type = "service"

constraint {
attribute = "${attr.cpu.arch}"
operator = "="
value = "amd64"
}

group "faas-nomadd" {
count = 1

restart {
attempts = 10
interval = "5m"
delay = "25s"
mode = "delay"
}

task "nomadd" {
driver = "docker"

env {
NOMAD_REGION = "${NOMAD_REGION}"
NOMAD_ADDR = "${NOMAD_IP_http}:4646"
CONSUL_ADDR = "${NOMAD_IP_http}:8500"
STATSD_ADDR = "${NOMAD_ADDR_statsd_statsd}"
}

config {
image = "localhost:5000/faas-nomad:latest"

port_map {
http = 8080
}
}

resources {
cpu = 500 # 500 MHz
memory = 128 # 128MB

network {
mbits = 10

port "http" {
static = 8081
}
}
}

service {
port = "http"
name = "faasd-nomad"
tags = ["faas"]
}
}

task "gateway" {
driver = "docker"
template {
env = true
destination = "secrets/gateway.env"

data = <<EOH
functions_provider_url="http://{{ env "NOMAD_IP_http" }}:8081/"
{{ range service "prometheus" }}
faas_prometheus_host="{{ .Address }}"
faas_prometheus_port="{{ .Port }}"{{ end }}
EOH
}

config {
image = "functions/gateway:0.6.14"

port_map {
http = 8080
}
}

resources {
cpu = 500 # 500 MHz
memory = 128 # 128MB

network {
mbits = 10

port "http" {
static = 8080
}
}
}

service {
port = "http"
name = "gateway"
tags = ["faas"]
}
}

task "statsd" {
driver = "docker"

config {
image = "prom/statsd-exporter:v0.4.0"

args = [
"-log.level=debug",
]
}

resources {
cpu = 100 # 100 MHz
memory = 36 # 36MB

network {
mbits = 1

port "http" {
static = 9102
}

port "statsd" {
static = 9125
}
}
}

service {
port = "http"
name = "statsd"
tags = ["faas"]

check {
type = "http"
port = "http"
interval = "10s"
timeout = "2s"
path = "/"
}
}
}
}
}

0 comments on commit d60a081

Please sign in to comment.