Skip to content

Commit f7cfa31

Browse files
authored
Merge branch 'main' into build-config-env
2 parents 16c3a42 + 8464a43 commit f7cfa31

File tree

26 files changed

+504
-331
lines changed

26 files changed

+504
-331
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Install pack
2727
uses: buildpacks/github-actions/[email protected]
2828
with:
29-
pack-version: '0.30.0-rc1' # FIXME: update to 0.30.0 when available
29+
pack-version: '0.31.0'
3030
- name: Test
3131
run: make test
3232
env:

content/docs/app-developer-guide/run-an-app.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Base Image:
4848
Top Layer: sha256:700c764e7c5d5c75e6a0fc7d272b7e1c70ab327c03fbdf4abd9313e5ec3217f7
4949
5050
Run Images:
51-
cnbs/sample-stack-run:alpine
51+
cnbs/sample-base-run:alpine
5252
5353
Rebasable: true
5454

content/docs/buildpack-author-guide/create-buildpack/adding-bill-of-materials.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ You should see the following:
2525
<!-- test:assert=contains;ignore-lines=... -->
2626
```text
2727
Run Images:
28-
cnbs/sample-stack-run:jammy
28+
cnbs/sample-base-run:jammy
2929
...
3030
3131
Buildpacks:
@@ -55,9 +55,13 @@ api = "0.8"
5555
version = "0.0.1"
5656
sbom-formats = [ "application/vnd.cyclonedx+json" ]
5757

58-
# Stacks that the buildpack will work with
58+
# Targets the buildpack will work with
59+
[[targets]]
60+
os = "linux"
61+
62+
# Stacks (deprecated) the buildpack will work with
5963
[[stacks]]
60-
id = "io.buildpacks.samples.stacks.jammy"
64+
id = "*"
6165
```
6266

6367
Then, in our buildpack implementation we will generate the necessary SBOM metadata:

content/docs/buildpack-author-guide/create-buildpack/building-blocks-cnb.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ This command will create `ruby-buildpack` directory which contains `buildpack.to
2828
### Additional Parameters
2929
- `-a, --api` Buildpack API compatibility of the generated buildpack
3030
- `-h, --help` Help for 'new'
31-
- `--path` the location on the filesystem to generate the artifacts.
32-
- `--stacks` Stack(s) this buildpack will be compatible with. Repeat for each stack in order, or supply once by comma-separated list
31+
- `--path` the location on the filesystem to generate the artifacts
32+
- `--stacks` Stacks (deprecated) the buildpack will work with
3333
- `-V, --version` the version of the buildpack in buildpack.toml
3434

3535

@@ -48,13 +48,19 @@ api = "0.8"
4848
id = "examples/ruby"
4949
version = "0.0.1"
5050

51-
# Stacks that the buildpack will work with
51+
# Targets the buildpack will work with
52+
[[targets]]
53+
os = "linux"
54+
55+
# Stacks (deprecated) the buildpack will work with
5256
[[stacks]]
5357
id = "io.buildpacks.samples.stacks.jammy"
5458

5559
```
5660

57-
You will notice two specific fields in the file: `buildpack.id` and `stack.id`. The buildpack ID is the way you will reference the buildpack when you create buildpack groups, builders, etc. The stack ID is the root file system in which the buildpack will be run. This example can be run on one of two different stacks, both based upon Ubuntu Bionic.
61+
The buildpack ID is the way you will reference the buildpack when you create buildpack groups, builders, etc.
62+
[Targets](/docs/concepts/components/targets/) identifies the kind of build and run base images the buildpack will work with.
63+
The stack ID (deprecated) uniquely identifies a build and run image configuration the buildpack will work with. This example can be run on Ubuntu Jammy.
5864

5965
### `detect` and `build`
6066

content/docs/concepts/_index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ For example:
4747

4848
![builder](/docs/concepts/builder.svg)
4949

50-
[`Builders`](/docs/concepts/components/builder) are an ordered combination of [`buildpacks`](/docs/concepts/components/buildpack) with a base `build` image, a lifecycle, and reference to a `run image`. They take in your `app` source code and build the output `app image`. The `build` image provides the base environment for the `builder` (for eg. an Ubuntu Bionic OS image with build tooling) and a `run` image provides the base environment for the `app image` during runtime. A combination of a `build` image and a `run` image is called a [`stack`](/docs/concepts/components/stack).
50+
[`Builders`](/docs/concepts/components/builder) are an ordered combination of [`buildpacks`](/docs/concepts/components/buildpack) with a base `build image`, a lifecycle, and reference to a `run image`.
51+
They take in your `app` source code and build the output `app image`. The `build image` provides the base environment for the `builder` (for eg. an Ubuntu Bionic OS image with build tooling) and a `run image` provides the base environment for the `app image` during runtime.
5152

5253
Under the hood a builder uses the [`lifecycle`](/docs/concepts/components/lifecycle) to run the `detect` phase for all the `buildpacks` it contains in order and then proceeds to run the `build` phase of all the `buildpacks` that passed detection.
5354

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
+++
2+
title="Build image"
3+
weight=1
4+
+++
5+
6+
## What is a build image?
7+
8+
The **build image** provides the base image from which the build environment is constructed.
9+
The build environment is the containerized environment in which the [lifecycle][lifecycle] (and thereby [buildpacks][buildpack]) are executed.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
+++
2+
title="Run image"
3+
weight=2
4+
+++
5+
6+
## What is a run image?
7+
8+
The **run image** provides the base image for application images.
9+
The lifecycle requires a reference to a run image and (where necessary) possible run image mirrors in order to construct the application image.
10+
11+
### Run image mirrors
12+
13+
Run image mirrors provide alternate locations for run images, for use during `build` or `rebase`.
14+
When running `build` with a builder containing run image mirrors, `pack` will select a run image
15+
whose registry location matches that of the specified app image (if no registry host is specified in the image name,
16+
DockerHub is assumed). This is useful when publishing the resulting app image (via the `--publish` flag or via
17+
`docker push`), as the app's base image (i.e. run image) will be located on the same registry as the app image itself,
18+
reducing the amount of data transfer required to push the app image.
19+
20+
In the following example, assuming a builder configured with the example TOML above, the selected run image will be
21+
`registry.example.com/example/run`.
22+
23+
```bash
24+
$ pack build registry.example.com/example/app
25+
```
26+
27+
while naming the app without a registry specified, `example/app`, will cause `example/run` to be selected as the app's
28+
run image.
29+
30+
```bash
31+
$ pack build example/app
32+
```
33+
34+
> For local development, it's often helpful to override the run image mirrors in a builder. For this, the
35+
> `pack config run-image-mirrors` command can be used. This command does not modify the builder, and instead configures the
36+
> local environment.
37+
>
38+
> To see what run images are configured for a builder, the
39+
> `builder inspect` command can be used. `builder inspect` will output built-in and locally-configured run images for
40+
> a given builder, along with other useful information. The order of the run images in the output denotes the order in
41+
> which they will be matched during `build`.

content/docs/concepts/components/builder.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ aliases=[
1818
A builder consists of the following components:
1919

2020
* [Buildpacks][buildpack]
21-
* [Lifecycle][lifecycle]
22-
* [Stack's][stack] build image
21+
* A [lifecycle][lifecycle]
22+
* A [build image](/docs/concepts/components/base-images/build/)
23+
* A reference to a [run image](/docs/concepts/components/base-images/run/)
2324

2425
### Resources
2526

@@ -29,4 +30,3 @@ To learn how to create your own builder, see our [Operator's Guide][operator-gui
2930
[operator-guide]: /docs/operator-guide/
3031
[buildpack]: /docs/concepts/components/buildpack/
3132
[lifecycle]: /docs/concepts/components/lifecycle/
32-
[stack]: /docs/concepts/components/stack/

content/docs/concepts/components/stack.md

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,26 @@ aliases=[
88

99
## What is a stack?
1010

11-
A stack is composed of two images that are intended to work together:
11+
A stack (deprecated) is the grouping together of the build and run base images, represented by a unique ID.
1212

13-
1. The **build image** of a stack provides the base image from which the build environment is constructed. The build environment is the containerized environment in which the [lifecycle][lifecycle] (and thereby [buildpacks][buildpack]) are executed.
14-
2. The **run image** of a stack provides the base image from which application images are built.
13+
As of Platform API 0.12 and Buildpack API 0.10, stacks are deprecated in favor of existing constructs in the container image ecosystem such as operating system name, operating system distribution, and architecture.
14+
15+
For more information, see
16+
* Platform API 0.12 [migration guide](/docs/reference/spec/migration/platform-api-0.11-0.12/)
17+
* Buildpack API 0.10 [migration guide](/docs/reference/spec/migration/buildpack-api-0.9-0.10/)
18+
* [Build image](/docs/concepts/components/base-images/build/) concept
19+
* [Run image](/docs/concepts/components/base-images/run/) concept
20+
* [Target data](/docs/concepts/components/targets/)
21+
22+
For older API versions, see below on using stacks.
1523

1624
<!--more-->
1725

26+
## Using stacks
27+
1828
> If you're using the `pack` CLI, running `pack stack suggest` will display a list of recommended
1929
stacks that can be used when running `pack builder create`, along with each stack's associated build and run images.
2030

21-
## Using stacks
22-
2331
Stacks are used by [builders][builder] and are configured through a builder's
2432
[configuration file](/docs/reference/config/builder-config/):
2533

@@ -40,38 +48,6 @@ Stacks are used by [builders][builder] and are configured through a builder's
4048
By providing the required `[stack]` section, a builder author can configure a stack's ID, build image, and run image
4149
(including any mirrors).
4250

43-
### Run image mirrors
44-
45-
Run image mirrors provide alternate locations for run images, for use during `build` (or `rebase`).
46-
When running `build` with a builder containing run image mirrors, `pack` will select a run image
47-
whose registry location matches that of the specified app image (if no registry host is specified in the image name,
48-
DockerHub is assumed). This is useful when publishing the resulting app image (via the `--publish` flag or via
49-
`docker push`), as the app's base image (i.e. run image) will be located on the same registry as the app image itself,
50-
reducing the amount of data transfer required to push the app image.
51-
52-
In the following example, assuming a builder configured with the example TOML above, the selected run image will be
53-
`registry.example.com/example/run`.
54-
55-
```bash
56-
$ pack build registry.example.com/example/app
57-
```
58-
59-
while naming the app without a registry specified, `example/app`, will cause `example/run` to be selected as the app's
60-
run image.
61-
62-
```bash
63-
$ pack build example/app
64-
```
65-
66-
> For local development, it's often helpful to override the run image mirrors in a builder. For this, the
67-
> `pack config run-image-mirrors` command can be used. This command does not modify the builder, and instead configures the
68-
> user's local machine.
69-
>
70-
> To see what run images are configured for a builder, the
71-
> `inspect-builder` command can be used. `inspect-builder` will output built-in and locally-configured run images for
72-
> a given builder, among other useful information. The order of the run images in the output denotes the order in
73-
> which they will be matched during `build`.
74-
7551
## Resources
7652

7753
To learn how to create your own stack, see our [Operator's Guide][operator-guide].
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
+++
2+
title="Targets"
3+
weight=4
4+
+++
5+
6+
The concept of "targets" is used to identify compatibility between buildpacks and base images.
7+
8+
Target data includes:
9+
* Operating system name (e.g., "linux")
10+
* Architecture (e.g., "amd64", "arm64")
11+
* Architecture variant
12+
* Operating system distribution name (e.g., "ubuntu", "alpine")
13+
* Operating system distribution version (e.g., "22.04", "3.18.3")
14+
15+
For Linux-based images, operating system distribution name and version should be the values in `/etc/os-release` (`$ID` and `$VERSION_ID`).
16+
For Windows-based images, operating system distribution name is blank, and version should be the value of `os.version` in the image config (e.g., `10.0.14393.1066`).
17+
18+
Buildpacks may declare the targets they are compatible with in `buildpack.toml`.
19+
This information will be used by `pack` (or other platforms) and the lifecycle to avoid running buildpacks on images they aren't designed to work with.
20+
21+
Additionally, during builds this information will be read by the lifecycle from the run image and exposed to buildpacks through `CNB_TARGET_` environment variables:
22+
* `CNB_TARGET_OS`
23+
* `CNB_TARGET_ARCH`
24+
* `CNB_TARGET_ARCH_VARIANT`
25+
* `CNB_TARGET_DISTRO_NAME`
26+
* `CNB_TARGET_DISTRO_VERSION`
27+
28+
Buildpacks can use this information to modify their behavior depending on the target.

0 commit comments

Comments
 (0)