Use an inline buildpack

You can supplement your app’s build process with custom scripts by creating an inline buildpack. An inline buildpack is an ephemeral buildpack that’s defined in your project descriptor (i.e. project.toml). You can include a script to run as part of the build without setting up all the files and directories that are required for a complete buildpack.

Inline buildpacks are defined as an entry in the [[]] table of the project descriptor by including an inline script in the [] table.

For example, you may want to run a Rake task against a Ruby app after the Ruby buildpack builds your app.

schema-version = "0.2"
id = ""

id = "example/ruby"
version = "1.0"

id = "me/rake-tasks"

  api = "0.10"
  inline = "rake package"

In this example, the me/rake-tasks inline buildpack is configured to run after the example/ruby buildpack. The inline script is compatible with Buildpack API version 0.6 (this is a required field), and it will execute the rake package command during the build step.

Note: Inline buildpacks will always pass detection.

Inline buildpacks aren’t constrained to a single command, however. You can define complex scripts as heredocs in your project descriptor. For example, this snippet of a descriptor will source a shell script contained in the app repo, use it to modify the app directory (and thus the files that go into the final image), and create slices for the app:

id = "me/cleanup"

  api = "0.10"
  inline = """
set -e
source scripts/
find . -type f -name $(my_data_files) -delete
cat <<EOF > ${1}/launch.toml
type = 'bash'
command = 'bin/bash'

Further Reading

For more about project descriptors, look at the schema, as well as the specification.