If you’ve already used OpenFaaS, then you’ll be familiar with the faas-cli build and faas-cli up commands. These are convenient wrappers for Docke

How to build functions from source code with the Function Builder API

submited by
Style Pass
2022-06-23 10:00:06

If you’ve already used OpenFaaS, then you’ll be familiar with the faas-cli build and faas-cli up commands. These are convenient wrappers for Docker, that can be used on your own machine during development, and on a CI server to publish new versions of your functions. The Template Store is a handy way to find templates for writing functions that you can also customise if you need.

How does faas-cli work? It takes a template, and then overlays your code on top, making a build context. The build context is then passed over to Docker, which finds the Dockerfile at the root-level, and all your code, and gets to work building an OCI-compatible container image, which can be deployed to OpenFaaS.

The Function Builder API provides a secure way to build containers using via a HTTP REST call, making it easy to integrate with your existing tools and products. It doesn’t need root privileges, and makes use of BuildKit which was developed by the Docker community, for fast, efficient and isolated builds.

We’ll show you how to use the builder using curl which will give you everything you need to write your own integration in code, but we’re also providing examples for Python and Node.js to get you started.

Leave a Comment