Paketo Buildpacks
website·Indexed 35 days ago
https://paketo.io/docs/Documentation for Paketo Buildpacks, providing guides and references for building cloud-native applications in Java, Node.js, Python, Go, .NET Core, PHP, and Ruby. Includes technical details on builders, stacks, Software Bill of Materials (SBOM), and custom buildpack creation using the Packit library.
What's inside Paketo
- Paketo Buildpacks are open-source tools that transform application source code into OCI-compliant container images. They automatically detect the application language, gather required dependencies, and build the image. They are designed to run on any platform supporting container images, such as Docker and Kubernetes, and integrate with CI/CD tools like CircleCI, GitLab, and Tekton. They are also utilized by tools such as the Pack CLI, Spring Boot, Hashicorp Waypoint, and Tilt.
Overview of Paketo PHP Buildpack components
The Paketo PHP buildpack is composed of multiple specialized components. Some are required for a basic PHP runtime, while others are optional for specific server or session requirements:
Required Components:
- PHP Dist Buildpack: Installs the PHP distribution and adds it to the
$PATH. - PHP FPM Buildpack: Configures the
php-fpm.conffile.
Optional Components:
- Composer/Composer Install: Installs the Composer tool and runs
composer install. - Web Servers: Includes
httpd(Apache),nginx, andphp-builtin-serverfor serving applications. - Server Integration:
php-httpdandphp-nginxconfigure the respective servers to serve PHP apps;php-startsets the start command for NGINX or HTTPD with FPM. - Session Handlers: Specialized buildpacks for Redis and Memcached session handling.
- General Utilities:
procfile(custom start commands),environment-variables(launch-time vars),image-labels(image metadata), andca-certificates(custom CA certs).
- PHP Dist Buildpack: Installs the PHP distribution and adds it to the
Understand the components of a Paketo builder
A builder is a specialized image used by the
packCLI to create a runnable application image. It consists of three primary components:- Buildpacks: A set of tools that provide the necessary dependencies for the application.
- Stack: The operating system (OS) layer that serves as the foundation for the app image.
- CNB Lifecycle: The mechanism that orchestrates the buildpacks and stack to produce the final application image.
Understand the Paketo Buildpack lifecycle
Paketo Buildpacks transform application source code into OCI-compliant images using a two-phase process:
- Detect Phase: The buildpack scans the source code for specific indicators (e.g., the presence of a
package.jsonfile for the NPM Install Buildpack) to determine if it is required for the build. If detection passes, the buildpack defines a contract of what it requires and what it will provide. - Build Phase: The buildpack fulfills its contract by contributing to the final image. This may involve adding a layer containing a binary (like a language runtime) or executing a command (like
npm install).
- Detect Phase: The buildpack scans the source code for specific indicators (e.g., the presence of a
Understand Paketo NGINX Buildpack behavior
The NGINX Buildpack contributes to a build in three ways depending on the source code and configuration:
- Custom Config: If an
nginx.conffile is present in the app's source code, the buildpack sets up an NGINX server using that configuration. - Dependency Only: If
nginx.confis absent andBP_WEB_SERVERis not set tonginx, the buildpack installs the NGINX binary distribution onto the$PATHfor use by subsequent buildpacks but does not set up a server. - Default Config: If the environment variable
BP_WEB_SERVERis set tonginx, the buildpack sets up an NGINX server using a default configuration.
- Custom Config: If an
Compare Paketo Buildpacks with Cloud Foundry Buildpacks
Paketo Buildpacks differ from Cloud Foundry (CF) Buildpacks in three primary ways:
- Portability: Paketo produces OCI images that can be deployed anywhere, whereas CF produces droplets that require the CF environment.
- Architecture: Paketo uses small, composable components; CF uses monolithic codebases for each language.
- Extensibility: Paketo allows users to add features by writing new buildpacks, while CF typically requires forking the existing buildpack.
Retrieve Software Bill of Materials (SBOM) for PHP apps
The PHP buildpack generates a full SBOM including PHP versions, Composer versions, and all packages installed via Composer. Supported formats include Syft (JSON), CycloneDX, SPDX, and Paketo-specific formats.Paketo Java Native Image Buildpack components overview
The Paketo Java Native Image Buildpack is composed of several component buildpacks. The core requirements for creating a native image are the Paketo GraalVM Buildpack (providing the JDK and Substrate VM) and the Paketo Native Image Buildpack (which handles the conversion from JVM application to native image). Other optional components support specific build tools (Maven, Gradle, SBT, Leiningen), Spring Boot configuration, and image metadata (labels, environment variables, CA certificates).Deploy .NET Core applications using different artifact types
The buildpack supports three primary deployment types:
- Source Applications: Built using
dotnet publishinto FDD or FDE. - Framework-Dependent Deployments (FDD) / Executables (FDE): The buildpack includes required .NET Core Framework dependencies and sets the start command.
- Self-Contained Deployments (SCD): The buildpack sets the start command; no additional .NET Core Framework dependencies are included as they are bundled in the SCD artifact.
- Source Applications: Built using
Understand Paketo Software Bill of Materials (SBOM) concepts
A Software Bill of Materials (SBOM) in Paketo is a mechanism to surface metadata about dependencies within an app image. This metadata is used for secure software supply chain management, specifically for vulnerability scanning (using CPEs and pURLs) and legal compliance checking (via SPDX license information).
Key metadata fields include:
version: Dependency versionuri: URI to the compiled dependencychecksum: CycloneDX-supported hash (e.g., SHA-256)licenses: Dependency licenses in SPDX formatdeprecation-date: Date the dependency was deprecatedsource uriandsource checksum: Details of the upstream sourceCPE: Common Platform Enumeration for NIST NVD lookupspURL: Package URL for universal package representation
Understand Paketo Stack architecture
A Paketo stack provides the build-time and run-time environments for the buildpack lifecycle. It consists of two distinct images:
- Build Image: The environment where the application is compiled and built.
- Run Image: The OS layer on which the application actually executes.
This separation ensures that the runtime environment is curated to exclude compilers and other tools that could pose security risks.
Understand Paketo HTTPD Buildpack behavior
The HTTPD Buildpack installs the Apache HTTP Server binary distribution onto the
$PATHinside a container. Its behavior during a build depends on the following conditions:- If
httpd.confis present in the app's source code: The buildpack sets up an Apache HTTP server using that specific configuration. - If
httpd.confis absent: The buildpack provides the Apache HTTP Server dependency to subsequent buildpacks but does not set up a server. - If the environment variable
BP_WEB_SERVERis set tohttpd: The buildpack sets up an Apache HTTP server using a default configuration.
- If