Note: For the Docker Swarm setup, check out the official guide.
bash setup.sh [<OPENFAAS-HOME-DIRECTORY>]
whereby OPENFAAS-HOME-DIRECTORY
defaults to /data/openfaas
.
Note down the credentials which you will need later.
Note: For the Docker Swarm setup, check out the official guide.
bash setup.sh [<OPENFAAS-HOME-DIRECTORY>]
whereby OPENFAAS-HOME-DIRECTORY
defaults to /data/openfaas
.
Note down the credentials which you will need later.
#!/usr/bin/env bash | |
## Stop on errors: | |
set -e | |
## Get the OpenFAAS home: | |
OPENFAAS_HOME="${1:-/data/openfaas}" | |
## Check if the OpenFAAS home can be created later: | |
echo "Checking if OpenFAAS home can be created..." | |
if mkdir "${OPENFAAS_HOME}"; then | |
echo "OpenFAAS home can be created. Proceeding..." | |
rmdir "${OPENFAAS_HOME}" | |
else | |
echo "OpenFAAS home can not be created. Exiting..." >&2 | |
exit 1 | |
fi | |
## Check if we have swarm. If yes, stop as we do not want to mess up. | |
if docker info 2>&1 | grep -o "Swarm: active" > /dev/null; then | |
echo "We already have a swarm. Exiting..." >&2 | |
exit 1 | |
else | |
echo "No swarm detected. Creating..." | |
docker swarm init | |
fi | |
## Clone OpenFAAS repository: | |
echo "Cloning OpenFAAS repository..." | |
git clone https://github.com/openfaas/faas "${OPENFAAS_HOME}" | |
## Deploy OpenFAAS stack: | |
echo "Deploying OpenFAAS stack..." | |
cd "${OPENFAAS_HOME}" || exit 1 | |
./deploy_stack.sh | |
cd - || exit 1 |