mirror of
https://github.com/openfaas/faas.git
synced 2025-06-11 17:56:47 +00:00
Update to support docker stack deploy
This commit is contained in:
parent
78f751312e
commit
eb0776e3a3
@ -12,7 +12,7 @@ Minimum requirements:
|
|||||||
* Docker 1.13-RC (to support attachable overlay networks)
|
* Docker 1.13-RC (to support attachable overlay networks)
|
||||||
* At least a single host in Swarm Mode. (run `docker swarm init`)
|
* At least a single host in Swarm Mode. (run `docker swarm init`)
|
||||||
|
|
||||||
> For more information on Swarm mode and configuration please have a look at the [Swarm Mode tutorial](https://docs.docker.com/engine/swarm/swarm-tutorial/)
|
`For more information on Swarm mode and configuration please have a look at the [Swarm Mode tutorial](https://docs.docker.com/engine/swarm/swarm-tutorial/). `
|
||||||
|
|
||||||
Check your `docker version` and upgrade to one of the latest 1.13-RCs from the [Docker Releases page](https://github.com/docker/docker/releases). This is already available through the Beta channel in Docker for Mac.
|
Check your `docker version` and upgrade to one of the latest 1.13-RCs from the [Docker Releases page](https://github.com/docker/docker/releases). This is already available through the Beta channel in Docker for Mac.
|
||||||
|
|
||||||
|
20
build.sh
Executable file
20
build.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# First do - git clone https://github.com/alexellis/faas && cd faas
|
||||||
|
|
||||||
|
docker network create --driver overlay --attachable functions
|
||||||
|
|
||||||
|
cd watchdog
|
||||||
|
./build.sh
|
||||||
|
|
||||||
|
cp ./fwatchdog ../sample-functions/catservice/
|
||||||
|
|
||||||
|
docker build --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy \
|
||||||
|
-t alexellis2/faas-catservice .
|
||||||
|
docker service rm catservice ; docker service create --network=functions --name catservice alexellis2/faas-catservice
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
cd gateway
|
||||||
|
./build.sh
|
||||||
|
docker rm -f server; docker run -d -v /var/run/docker.sock:/var/run/docker.sock --name server -p 8080:8080 --network=functions alexellis2/faas-gateway
|
5
deploy_stack.sh
Executable file
5
deploy_stack.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "Deploying stack"
|
||||||
|
docker stack rm func ; docker stack deploy func --compose-file docker-compose.yml
|
||||||
|
|
27
docker-compose.yml
Normal file
27
docker-compose.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
gateway:
|
||||||
|
volumes:
|
||||||
|
- "/var/run/docker.sock:/var/run/docker.sock"
|
||||||
|
ports:
|
||||||
|
- 3000:8080
|
||||||
|
image: alexellisio/faas-gateway:latest
|
||||||
|
networks:
|
||||||
|
- functions
|
||||||
|
prometheus:
|
||||||
|
image: quay.io/prometheus/prometheus:latest
|
||||||
|
volumes:
|
||||||
|
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
|
||||||
|
command: "-config.file=/etc/prometheus/prometheus.yml -storage.local.path=/prometheus -storage.local.memory-chunks=10000"
|
||||||
|
ports:
|
||||||
|
- 9090:9090
|
||||||
|
depends_on:
|
||||||
|
- gateway
|
||||||
|
environment:
|
||||||
|
no_proxy: "gateway"
|
||||||
|
networks:
|
||||||
|
- functions
|
||||||
|
networks:
|
||||||
|
functions:
|
||||||
|
driver: overlay
|
||||||
|
#attachable: true
|
@ -1,19 +1,9 @@
|
|||||||
from golang:1.7.3
|
FROM golang:1.7.3
|
||||||
|
|
||||||
RUN go get -d github.com/docker/docker/api/types \
|
COPY gateway .
|
||||||
&& go get -d github.com/docker/docker/api/types/filters \
|
|
||||||
&& go get -d github.com/docker/docker/api/types/swarm \
|
|
||||||
&& go get -d github.com/docker/docker/client \
|
|
||||||
&& go get github.com/gorilla/mux \
|
|
||||||
&& go get github.com/prometheus/client_golang/prometheus
|
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/alexellis/faas/gateway
|
|
||||||
|
|
||||||
COPY metrics metrics
|
|
||||||
COPY server.go .
|
|
||||||
|
|
||||||
RUN find /go/src/github.com/alexellis/faas/gateway/
|
|
||||||
RUN go build
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
ENV http_proxy ""
|
||||||
|
ENV https_proxy ""
|
||||||
|
|
||||||
CMD ["./gateway"]
|
CMD ["./gateway"]
|
||||||
|
16
gateway/Dockerfile.build
Normal file
16
gateway/Dockerfile.build
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
FROM golang:1.7.3
|
||||||
|
|
||||||
|
RUN go get -d github.com/docker/docker/api/types \
|
||||||
|
&& go get -d github.com/docker/docker/api/types/filters \
|
||||||
|
&& go get -d github.com/docker/docker/api/types/swarm \
|
||||||
|
&& go get -d github.com/docker/docker/client \
|
||||||
|
&& go get github.com/gorilla/mux \
|
||||||
|
&& go get github.com/prometheus/client_golang/prometheus
|
||||||
|
|
||||||
|
WORKDIR /go/src/github.com/alexellis/faas/gateway
|
||||||
|
|
||||||
|
COPY metrics metrics
|
||||||
|
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 .
|
@ -1,4 +1,13 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
echo Building server:latest
|
echo Building alexellis2/faas-gateway:build
|
||||||
|
|
||||||
docker build -t server .
|
docker build --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy \
|
||||||
|
-t alexellis2/faas-gateway:build . -f Dockerfile.build
|
||||||
|
|
||||||
|
docker create --name gateway_extract alexellis2/faas-gateway:build
|
||||||
|
docker cp gateway_extract:/go/src/github.com/alexellis/faas/gateway/app ./gateway
|
||||||
|
docker rm -f gateway_extract
|
||||||
|
|
||||||
|
echo Building alexellis2/faas-gateway:latest
|
||||||
|
|
||||||
|
docker build -t alexellis2/faas-gateway:latest .
|
||||||
|
BIN
monitor/._prometheus.yml
Executable file
BIN
monitor/._prometheus.yml
Executable file
Binary file not shown.
12
oneshot.sh
12
oneshot.sh
@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
docker network create --driver overlay --attachable functions
|
|
||||||
git clone https://github.com/alexellis/faas && cd faas
|
|
||||||
cd watchdog
|
|
||||||
./build.sh
|
|
||||||
docker build -t catservice .
|
|
||||||
docker service rm catservice ; docker service create --network=functions --name catservice catservice
|
|
||||||
cd ..
|
|
||||||
cd gateway
|
|
||||||
docker build -t server . ;docker rm -f server; docker run -d -v /var/run/docker.sock:/var/run/docker.sock --name server -p 8080:8080 --network=functions server
|
|
||||||
|
|
34
prometheus/prometheus.yml
Normal file
34
prometheus/prometheus.yml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# my global config
|
||||||
|
global:
|
||||||
|
scrape_interval: 15s # By default, scrape targets every 15 seconds.
|
||||||
|
evaluation_interval: 15s # By default, scrape targets every 15 seconds.
|
||||||
|
# scrape_timeout is set to the global default (10s).
|
||||||
|
|
||||||
|
# Attach these labels to any time series or alerts when communicating with
|
||||||
|
# external systems (federation, remote storage, Alertmanager).
|
||||||
|
external_labels:
|
||||||
|
monitor: 'codelab-monitor'
|
||||||
|
|
||||||
|
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
|
||||||
|
rule_files:
|
||||||
|
# - "first.rules"
|
||||||
|
# - "second.rules"
|
||||||
|
|
||||||
|
# A scrape configuration containing exactly one endpoint to scrape:
|
||||||
|
# Here it's Prometheus itself.
|
||||||
|
scrape_configs:
|
||||||
|
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
|
||||||
|
- job_name: 'prometheus'
|
||||||
|
|
||||||
|
# Override the global default and scrape targets from this job every 5 seconds.
|
||||||
|
scrape_interval: 5s
|
||||||
|
|
||||||
|
# metrics_path defaults to '/metrics'
|
||||||
|
# scheme defaults to 'http'.
|
||||||
|
static_configs:
|
||||||
|
- targets: ['localhost:9090']
|
||||||
|
|
||||||
|
- job_name: "gateway"
|
||||||
|
scrape_interval: "15s"
|
||||||
|
static_configs:
|
||||||
|
- targets: ['gateway:8080']
|
@ -3,7 +3,8 @@
|
|||||||
# Below makes use of "builder pattern" so that binary is extracted separate
|
# Below makes use of "builder pattern" so that binary is extracted separate
|
||||||
# from the golang runtime/SDK
|
# from the golang runtime/SDK
|
||||||
|
|
||||||
docker build -t watchdog:latest .
|
docker build --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy \
|
||||||
docker create --name buildoutput watchdog:latest
|
-t alexellis2/faas-watchdog:build .
|
||||||
|
docker create --name buildoutput alexellis2/faas-watchdog:build
|
||||||
docker cp buildoutput:/go/src/app/app ./fwatchdog
|
docker cp buildoutput:/go/src/app/app ./fwatchdog
|
||||||
docker rm buildoutput
|
docker rm buildoutput
|
||||||
|
Loading…
x
Reference in New Issue
Block a user