Skip to content

Instantly share code, notes, and snippets.

@fardjad
Last active October 16, 2023 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fardjad/2cf28b2c79aba492fb040ffc3c678579 to your computer and use it in GitHub Desktop.
Save fardjad/2cf28b2c79aba492fb040ffc3c678579 to your computer and use it in GitHub Desktop.
[faas-cli Multi-Platform Run] Example of running a function on open-faas/faasd with faas-cli #faas_cli #open_faas #faasd

Steps

DOCKER_REGISTRY="registry.example.com"
PROJECT_NAME="hello-world"

# List the templates
faas-cli template store list --official --recommended --verbose=true

TEMPLATE="node18"

mkdir -p faas-example && cd faas-example

# Scaffold a new project
faas-cli new --lang "${TEMPLATE}" --prefix "${DOCKER_REGISTRY}" "${PROJECT_NAME}"

# Allows us to run publish and deploy sub-commands without the -f option
mv "${PROJECT_NAME}.yml" stack.yml

PLATFORMS="linux/amd64,linux/arm64"
# Builds and pushes the image to the registry
faas-cli publish --platforms "${PLATFORMS}"

OPENFAAS_URL="http://gateway.domain.tld:8080"
faas-cli deploy --gateway "${OPENFAAS_URL}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment