Skip to content

Commit 54f9d49

Browse files
authored
Merge branch 'main' into dependabot/github_actions/buildpacks/github-actions-5.5.3
2 parents d891cd9 + 579a70f commit 54f9d49

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+688
-686
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
runs-on: ubuntu-latest
5353
steps:
5454
- name: Download public folder
55-
uses: actions/download-artifact@v3
55+
uses: actions/download-artifact@v4
5656
with:
5757
name: public
5858
path: ./public

config.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,29 @@ featureKatacoda = false
9191
[security.http]
9292
methods = ['(?i)GET|POST']
9393
urls = ['.*']
94+
95+
# For more information, see https://gohugo.io/getting-started/directory-structure/#union-file-system
96+
[[module.mounts]]
97+
source = 'content'
98+
target = 'content'
99+
[[module.mounts]]
100+
source = 'content/docs/.common/concepts/buildpack.md'
101+
target = 'content/docs/for-app-developers/concepts/buildpack.md'
102+
[[module.mounts]]
103+
source = 'content/docs/.common/concepts/buildpack.md'
104+
target = 'content/docs/for-buildpack-authors/concepts/buildpack.md'
105+
[[module.mounts]]
106+
source = 'content/docs/.common/concepts/buildpack.md'
107+
target = 'content/docs/for-platform-operators/concepts/buildpack.md'
108+
[[module.mounts]]
109+
source = 'content/docs/.common/concepts/extension.md'
110+
target = 'content/docs/for-buildpack-authors/concepts/extension.md'
111+
[[module.mounts]]
112+
source = 'content/docs/.common/concepts/extension.md'
113+
target = 'content/docs/for-platform-operators/concepts/extension.md'
114+
[[module.mounts]]
115+
source = 'content/docs/.common/concepts/composite-buildpack.md'
116+
target = 'content/docs/for-buildpack-authors/concepts/composite-buildpack.md'
117+
[[module.mounts]]
118+
source = 'content/docs/.common/concepts/composite-buildpack.md'
119+
target = 'content/docs/for-platform-operators/concepts/composite-buildpack.md'
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
+++
2+
title="What is a buildpack?"
3+
weight=1
4+
+++
5+
6+
A `buildpack` is software that transforms application source code into runnable artifacts
7+
by analyzing the code and determining the best way to build it.
8+
9+
<!--more-->
10+
11+
![buildpacks](/images/what.svg)
12+
13+
## Why buildpacks?
14+
15+
Buildpacks allow application developers to focus on what they do best - writing code, without having to worry about image security, optimizing container images, or container build strategy.
16+
17+
How much time have you spent struggling to wrangle yet another Dockerfile? Copying and pasting random Dockerfile snippets into every project? Buildpacks can help! They are a better approach to building container images for applications.
18+
19+
## What do they look like?
20+
21+
Typical buildpacks consist of at least three files:
22+
23+
* `buildpack.toml` -- provides metadata about the buildpack, containing information such as its name, ID, and version.
24+
* `bin/detect` -- performs [detect](#detect).
25+
* `bin/build` -- performs [build](#build).
26+
27+
## How do they work?
28+
29+
![how](/images/how.svg)
30+
31+
**Each buildpack has two jobs to do**
32+
33+
### Detect
34+
35+
The buildpack determines if it is needed or not.
36+
37+
For example:
38+
39+
- A Python buildpack may look for a `requirements.txt` or a `setup.py` file.
40+
- A Node buildpack may look for a `package-lock.json` file.
41+
42+
### Build
43+
44+
The buildpack transforms application source code in some way, for example by
45+
46+
- Setting build-time and run-time environment variables.
47+
- Downloading dependencies.
48+
- Running source code compilation (if needed).
49+
- Configuring the application entrypoint and any startup scripts.
50+
51+
For example:
52+
53+
- A Python buildpack may run `pip install -r requirements.txt` if it detected a `requirements.txt` file.
54+
- A Node buildpack may run `npm install` if it detected a `package-lock.json` file.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
+++
2+
title="What is a composite buildpack?"
3+
weight=99
4+
+++
5+
6+
A composite buildpack, also sometimes called a "meta-buildpack",
7+
is a buildpack that does not contain any `./bin/detect` or `./bin/build` binaries,
8+
but instead references other buildpacks in its `buildpack.toml` via the `[[order]]` array.
9+
10+
This is useful for composing more complex detection strategies.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
2+
+++
3+
title="What is an image extension?"
4+
aliases=[
5+
"/docs/features/dockerfiles"
6+
]
7+
weight=99
8+
+++
9+
10+
An `image extension` is software that generates Dockerfiles that can be used to extend base images for buildpacks builds.
11+
12+
<!--more-->
13+
14+
## Why image extensions?
15+
16+
Buildpacks can do a lot, but there are some things buildpacks can't do. They can't install operating system packages,
17+
for example. Why not?
18+
19+
Buildpacks do not run as the `root` user and cannot make arbitrary changes to the filesystem. This enhances security,
20+
enables buildpack interoperability, and preserves the ability to rebase - but it comes at a cost. Base image authors
21+
must anticipate the OS-level dependencies that will be needed at build and run-time ahead of time, and this isn't always
22+
possible.
23+
24+
This has been a longstanding source of [discussion](https://github.com/buildpacks/rfcs/pull/173) within the CNB project:
25+
how can we preserve the benefits of buildpacks while enabling more powerful capabilities?
26+
27+
### Buildpacks and Dockerfiles can work together
28+
29+
Buildpacks are often presented as an alternative to Dockerfiles, but we think buildpacks and Dockerfiles can work
30+
together.
31+
32+
Buildpacks are optimized for creating layers that are efficient and logically mapped to the dependencies that they
33+
provide. By contrast, Dockerfiles are the most-used and best-understood mechanism for constructing base images and
34+
installing OS-level dependencies for containers.
35+
36+
The CNB Dockerfiles feature allows Dockerfiles to "provide" dependencies that buildpacks "require" through a
37+
shared [build plan], by introducing the concept of image extensions.
38+
39+
## What do they look like?
40+
41+
Image extensions are buildpack-like components that use a restricted `Dockerfile` syntax to expand base images. Their
42+
purpose is to generate Dockerfiles that can be used to extend the builder or run images prior to buildpacks builds.
43+
44+
An image extension could be defined with the following directory:
45+
46+
```
47+
.
48+
├── extension.toml <- similar to a buildpack buildpack.toml
49+
├── bin
50+
│ ├── detect <- similar to a buildpack ./bin/detect
51+
│ ├── generate <- similar to a buildpack ./bin/build
52+
```
53+
54+
* The `extension.toml` provides metadata about the extension, containing information such as its name, ID, and version.
55+
* `./bin/detect` performs [detect](#detect). It analyzes application source code to determine if the extension
56+
is needed and contributes build plan entries.
57+
* `./bin/generate` performs [generate](#generate) (a new lifecycle phase that happens after `detect`). It
58+
outputs either or both of `build.Dockerfile` or `run.Dockerfile` for extending the builder or run image.
59+
60+
## How do they work?
61+
62+
**Each image extension has two jobs to do**
63+
64+
### Detect
65+
66+
The extension determines if it is needed or not.
67+
68+
Like buildpacks, extensions participate in the `detect` phase - analyzing application source code to determine if they
69+
are needed. During `detect`, extensions can contribute to
70+
the [build plan] - recording dependencies that they are able to "
71+
provide" (though unlike buildpacks, they can't "require" anything).
72+
73+
If the provided order contains extensions, the output of `detect` will be a group of image extensions and a group of
74+
buildpacks that together produce a valid build plan. Image extensions only generate Dockerfiles - they don't create
75+
layers or participate in the `build` phase.
76+
77+
### Generate
78+
79+
The extension outputs Dockerfiles that can be used to extend either or both of the build-time base image and the runtime base image.
80+
81+
For more information and to see a build in action,
82+
see [authoring an image extension](/docs/for-buildpack-authors/tutorials/basic-extension).
83+
84+
[build plan]: /docs/for-buildpack-authors/how-to/write-buildpacks/use-build-plan

content/docs/buildpacks-logo.svg

Lines changed: 0 additions & 30 deletions
This file was deleted.

content/docs/for-app-developers/concepts/base-images/run.md

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,46 @@ The **run image** provides the base image for application images.
1111

1212
<!--more-->
1313

14-
The lifecycle requires a reference to a run image and (where necessary) possible run image mirrors in order to construct the application image.
14+
CNB tooling requires a reference to a run image and (where necessary) run image mirrors in order to construct the application image.
1515

1616
### Run image mirrors
1717

18-
Run image mirrors provide alternate locations for run images, for use during `build` or `rebase`.
19-
When running `build` with a builder containing run image mirrors, `pack` will select a run image
20-
whose registry location matches that of the specified app image (if no registry host is specified in the image name,
21-
DockerHub is assumed). This is useful when publishing the resulting app image (via the `--publish` flag or via
22-
`docker push`), as the app's base image (i.e. run image) will be located on the same registry as the app image itself,
23-
reducing the amount of data transfer required to push the app image.
18+
Run image mirrors provide alternate locations for `run images`, for use during `build` or `rebase`.
2419

25-
In the following example, assuming a builder configured with the example TOML above, the selected run image will be
26-
`registry.example.com/example/run`.
20+
When run image mirrors are defined, CNB tooling will try to find a run image that resides on the same registry as the application image,
21+
based on the image name provided.
2722

28-
```bash
29-
$ pack build registry.example.com/example/app
23+
This is to reduce the amount of data transfer required to push the application image to a registry.
24+
25+
#### Example - determining the registry
26+
27+
If the application image name is:
28+
29+
* `registry.example.com/example/app` - the registry is `registry.example.com`
30+
* `example/app` (registry omitted) - Docker Hub is assumed; the registry is `index.docker.io`
31+
32+
#### Example - determining the run image mirror
33+
34+
If your builder has a run image with mirrors defined as follows (see [how to create a builder](/docs/for-platform-operators/how-to/build-inputs/create-builder/builder) for more information):
35+
36+
```toml
37+
[[run.images]]
38+
image = "example/run"
39+
mirrors = ["registry.example.com/example/run"]
3040
```
3141

32-
while naming the app without a registry specified, `example/app`, will cause `example/run` to be selected as the app's
33-
run image.
42+
Then if you run `pack build` as follows:
3443

3544
```bash
36-
$ pack build example/app
45+
$ pack build registry.example.com/example/app
3746
```
3847

39-
> For local development, it's often helpful to override the run image mirrors in a builder. For this, the
40-
> `pack config run-image-mirrors` command can be used. This command does not modify the builder, and instead configures the
41-
> local environment.
48+
the selected run image will be `registry.example.com/example/run`.
49+
50+
> For local development, it's often helpful to override the run image mirrors in a builder.
51+
> For this, the `pack config run-image-mirrors` command can be used.
52+
> This command does not modify the builder, and instead configures the local environment.
4253
>
43-
> To see what run images are configured for a builder, the
44-
> `builder inspect` command can be used. `builder inspect` will output built-in and locally-configured run images for
45-
> a given builder, along with other useful information. The order of the run images in the output denotes the order in
46-
> which they will be matched during `build`.
54+
> To see what run images are configured for a builder, `pack builder inspect` can be used.
55+
> `pack builder inspect` will output built-in and locally-configured run images for a given builder, along with other useful information.
56+
> The order of the run images in the output denotes the order in which they will be matched during `build`.

content/docs/for-app-developers/concepts/build.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

content/docs/for-app-developers/concepts/builder.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

content/docs/for-app-developers/concepts/buildpack.md

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)