Build an app

Build is the process of executing one or more buildpacks against the app’s source code to produce a runnable OCI image.

Building an app using Cloud Native Buildpacks is as easy as 1, 2, 3

1. Select a builder

To build an app you must first decide what builder you are going to use. A builder includes the buildpacks that will be used as well as the environment for building and running your app.

When using pack, you can run pack suggest-builders for a list of suggested builders.

pack suggest-builders

For this turorial we’re actually going to use a sample builder, cnbs/sample-builder:bionic, which is not listed as a suggested builder for good reason. It’s a sample.

2. Build your app

Now that you’ve decided on what builder to use, we can build our app. For this example we will use our samples repo for simplicity.

# clone the repo
git clone https://github.com/buildpack/samples

# build the app
pack build sample-app --path samples/apps/java-maven/ --builder cnbs/sample-builder:bionic

Tip: If you didn’t want to keep specifying a builder every time you build, you could set it as your default builder by running pack set-default-builder <BUILDER>.

3. Run it

docker run --rm -p 8080:8080 sample-app

Congratulations!

The app should now be running and accessible via localhost:8080.