Use Sample Buildpacks
mainREADME.md file located within its specific directory.repository·main·Indexed 42 days ago
https://github.com/buildpacks/samplesA collection of sample implementations for Cloud Native Buildpacks (CNB) components. This repository provides developers with examples for testing and experimenting with apps, buildpacks, builders, base images, and packages, including guides for using the pack CLI, project descriptors (project.toml), and creating custom builders like alpine and resolute.
README.md file located within its specific directory.This repository contains sample builders that are built using the base images provided in this repository. These samples can be used to understand how to compose builders or to test buildpack behavior.
Available sample builders:
alpine/ directory.resolute/ directory.The project.toml file in this sample acts as a project descriptor for Cloud Native Buildpacks. It allows you to define how the project is described to the buildpacks and supports the following features:
The project.toml file in this sample acts as a project descriptor for Cloud Native Buildpacks. It allows you to define project-specific metadata and build instructions, including:
To specify a specific version of Ruby for the sample buildpack to install, create a .ruby-version file in the root of your application directory. The ruby-bundler sample buildpack uses this file to determine which Ruby version should be provisioned during the build process.
# Example .ruby-version file content
3.2.2The hello-world sample is a no-op buildpack designed to demonstrate the minimal requirements of a buildpack. You can build an application using this buildpack with the pack CLI by pointing to the current directory as the buildpack source and specifying a builder (either cnbs/sample-builder:alpine or cnbs/sample-builder:resolute). After building, you can verify the result by running the resulting Docker image and executing an echo command.
# Build using the alpine builder
pack build sample-hello-world-app --builder cnbs/sample-builder:alpine --buildpack .
# OR build using the resolute builder
pack build sample-hello-world-app --builder cnbs/sample-builder:resolute --buildpack .
# Run the resulting image
docker run sample-hello-world-app echo helloThe hello-moon buildpack is a no-op sample designed to demonstrate how buildpack dependencies function. It depends on the hello-world buildpack. You can build an application using this sample by specifying both the hello-world buildpack and the hello-moon buildpack (the current directory) in your pack build command.
# Using the alpine builder
pack build sample-hello-moon-app --builder cnbs/sample-builder:alpine --buildpack ../hello-world/ --buildpack .
# OR using the resolute builder
pack build sample-hello-moon-app --builder cnbs/sample-builder:resolute --buildpack ../hello-world/ --buildpack .To build a Ruby application that uses Bundler, use the pack CLI with the Ruby Bundler buildpack. This buildpack is compatible with Ruby applications that rely on Bundler for dependency management.
Ensure you point the --buildpack flag to the directory containing the buildpack and the --path flag to the directory containing your Ruby application source code.
pack build sample-ruby-bundler-app --builder cnbs/sample-builder:resolute --buildpack . --path ../../apps/ruby-bundlerThe hello-universe sample is a no-op meta-buildpack designed to demonstrate how to construct meta-buildpacks. You can use the pack CLI to build an application by specifying multiple buildpacks, including the current directory (the meta-buildpack itself) and other local buildpack directories.
pack build sample-hello-universe-app \
--builder cnbs/sample-builder:alpine \
--buildpack . \
--buildpack ../hello-world/ \
--buildpack ../hello-moon/Use the pack CLI to build a Java application that uses Maven. This sample buildpack is compatible with Java apps that utilize Maven for dependency management and builds.
To build the application, you must specify a builder (e.g., cnbs/sample-builder:alpine or cnbs/sample-builder:resolute), point the --buildpack flag to the current directory (.), and provide the path to the application source code using --path.
# Using the alpine builder
pack build sample-java-maven-app --builder cnbs/sample-builder:alpine --buildpack . --path ../../apps/java-maven
# OR using the resolute builder
pack build sample-java-maven-app --builder cnbs/sample-builder:resolute --buildpack . --path ../../apps/java-mavenUse this buildpack to build Kotlin applications that utilize the Gradle build system. You can build the application using the pack CLI by specifying the current directory as the buildpack and pointing to the application source path.
Note that you must provide a builder image (e.g., cnbs/sample-builder:alpine or cnbs/sample-builder:resolute) to execute the build.
# Using the alpine builder
pack build sample-kotlin-gradle-app --builder cnbs/sample-builder:alpine --buildpack . --path ../../apps/kotlin-gradle
# OR using the resolute builder
pack build sample-kotlin-gradle-app --builder cnbs/sample-builder:resolute --buildpack . --path ../../apps/kotlin-gradle