After developing and testing your Pulsar function, you need to package it so that the function can be submitted to a Pulsar cluster. You can package Pulsar Functions to external packages or images.
Before deploying a Pulsar function, you need to generate a deployment artifact that contains the function code along with all its dependencies. The type of artifact varies depending on the programming language used to develop the function.
For details about how to package a Java, Python, or Go function, see the Function Mesh documentation.
After packaging a function, you can build the function to a Docker image using the
Dockerfile or you can build a function image using Buildpacks.
Buildpacks allows you to build a function image through multiple buildpacks. This helps customize your code as required.
With Buildpacks, you can quickly change the runner base (
pulsar-function-<runtime>-runner) of a function image. And, you can use the
pack rebase <function-image> --run-image <new-runner-image> command to switch the runner image versions without building the function again.
This is an example of the directory structure of a buildpack for a Go function. Java and Python functions take the same directory structure.
| `-- golang-builder
| `-- builder.toml
| `-- golang
| |-- bin
| | |-- build
| | `-- detect
| `-- buildpack.toml
stack: the basic building and running environment for a function.
stack.build.Dockerfile: provides the Operating System (OS) environment for a function in the building phase.
stack.go-runner.run.Dockerfile: provides the OS environment for a function in the running phase.
buildpacks: checks whether the Java/Python/Go source-code files (such as with the
.gosuffix) and the required configuration files (such as
go.mo) exist. If these files exist, the buildpack will complete the build process. Typically, a buildpack consists of at least three files:
buildpack.toml: provides metadata about your buildpack.
bin/detect: determines whether the buildpack should be applied.
bin/build: executes the build logic.
builders: a builder is an image that contains all the components necessary to execute a build. A builder includes the buildpacks that will be used as well as the environment for building your function.
builder.toml: provides metadata about your builder.