Skip to content

Commit 13c5b65

Browse files
authored
Merge branch 'main' into restructure
2 parents 669c19b + 1e11511 commit 13c5b65

File tree

17 files changed

+1367
-24
lines changed

17 files changed

+1367
-24
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ jobs:
2323
go-version: '1.x'
2424
- name: Install Dependencies
2525
run: sudo apt-get install make curl jq
26+
- name: Install pack
27+
uses: buildpacks/github-actions/[email protected]
28+
with:
29+
pack-version: '0.28.0'
2630
- name: Test
2731
run: make test
2832
env:

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@ ifeq ($(OS),Windows_NT)
4040
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
4141
HUGO_ARCH:=64bit
4242
endif
43-
else
43+
endif
44+
4445
ifeq ($(shell uname -s),Darwin)
4546
HUGO_OS:=macOS
47+
HUGO_ARCH:=universal
4648
endif
47-
UNAME_M:=$(shell uname -m)
49+
50+
ifeq ($(shell uname -s),Linux)
51+
UNAME_M:=$(shell uname -m)
4852
ifneq ($(filter %64,$(UNAME_M)),)
4953
HUGO_ARCH:=64bit
5054
endif
@@ -70,8 +74,10 @@ endif
7074

7175
.PHONY: upgrade-pack
7276
upgrade-pack: pack-version
73-
@echo "> Upgrading pack library version $(PACK_VERSION)"
74-
cd tools; go get github.com/buildpacks/pack@v$(PACK_VERSION)
77+
@if [ ! $(`which pack` && `pack --version | cut -d '+' -f 1` != "$(PACK_VERSION)") ]; then \
78+
echo "> Upgrading pack library version $(PACK_VERSION)"; \
79+
cd tools; go get github.com/buildpacks/pack@v$(PACK_VERSION); \
80+
fi
7581

7682
.PHONY: install-pack-cli
7783
install-pack-cli: export PACK_BIN:=$(shell which pack)

content/docs/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ Find out the various ways that _you_ can contribute to the Cloud Native Buildpac
5858

5959
## Project Roadmap
6060

61-
This is a community driven project and our roadmap is publicly available on our [Github page](https://github.com/orgs/buildpacks/projects/1). We encourage you to contribute with feature requests.
61+
This is a community driven project and our roadmap is publicly available on our [Github page](https://github.com/buildpacks/community/blob/main/ROADMAP.md). We encourage you to contribute with feature requests.

content/docs/app-developer-guide/using-inline-buildpacks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ id = "me/rake-tasks"
2626
inline = "rake package"
2727
```
2828

29-
In this example, the `me/rake-tasks` inline buildpack is configured to run after the `example/ruby` buildpack. The inline script is compatible with API version `0.4` (this is a required field), and it will execute the `rake package` command during the build step.
29+
In this example, the `me/rake-tasks` inline buildpack is configured to run after the `example/ruby` buildpack. The inline script is compatible with buildpack API version `0.6` (this is a required field), and it will execute the `rake package` command during the build step.
3030

3131
> **Note:** Inline buildpacks will _always_ pass detection.
3232

content/docs/buildpack-author-guide/build-phases-overview.md

Lines changed: 379 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
+++
2+
title="Layer Types"
3+
weight=6
4+
summary="Learn strategies for caching layers."
5+
+++
6+
7+
# Layers
8+
9+
There are three types of layers that can be contributed to an image
10+
11+
* `build` layers -- the directory will be accessible by subsequent buildpacks,
12+
* `cache` layers -- the directory will be included in the cache,
13+
* `launch` layers -- the directory will be included in the run image as a single layer,
14+
15+
In this section we look at caching each layer type.
16+
17+
## Layer Metadata
18+
19+
buildpacks ensure byte-for-byte reproducibility of layers. File creation time is [normalized to January 1, 1980](https://medium.com/buildpacks/time-travel-with-pack-e0efd8bf05db) to ensure reproducibility. Byte-for-byte reproducibility means previous layers can be reused. However, we may want to invalidate previously cached layers if an important property changes, such as:
20+
21+
* the major version of the runtime changes eg: NodeJS changes from 16 to 18
22+
* requested application dependencies have changed eg: a Python application adds a dependency on the `requests` module
23+
24+
Launch layers are exported to an OCI registry. The layer metadata is commonly used when deciding if a launch layer should be re-used. A launch layer may be re-used on an OCI registry without downloading the layer to the machine running a build.
25+
26+
## Caching Strategies
27+
28+
Caching during the production of an application image is necessarily very flexible. Most buildpacks that wish to contribute a layer to the application image need only to
29+
30+
1. Check that the metadata of the cached layer is current,
31+
2. Create an empty layer, and
32+
3. Set `launch = true`.
33+
34+
This will guarantee that the previously published application image layer in the registry is re-used if the layer metadata matches the requested metadata. In this most straightforward use-case `launch` is `true` and both `build` and `cache` are set to `false`. That is to say, the most common case is where `cache = false`, `build = false` and `launch = true`. It is important to note that the layer is re-used on the OCI registry. This avoids expensive rebuilds of the layer and expensive pulls of the layer to the host running the build.
35+
36+
Setting `build = true` makes a layer available to subsequent buildpacks. Therefore binaries installed to the `bin` directory on a `build = true` layer are available to subsequent buildpacks during the build phase. It is also the case that `lib` directories on a `build = true` later are added to the `LD_LIBRARY_PATH` during the build phase of subsequent buildpacks. Environment variables defined in a `build = true` layer are similarly available. For any layer where `launch = true` and `build = true`, a launch layer from the OCI registry can no longer be reused. Instead, the layer must be made available locally so that subsequent buildpacks can use it.
37+
38+
Setting `cache = true` ensures that the layer is restored locally before the buildpacks build phase.
39+
40+
Setting `cache = false`, `build = false`, and `launch = true` is the most common configuration. If `cache = false`, `build = false`, and `launch = true` is not appropriate for your layer, then `cache = true`, `build = true`, and `launch = true` should be the next combination to evaluate:
41+
42+
* When `cache = true, build = true, launch = true`, explicitly setting `build = true` makes the layer available, to subsequent buildpacks, during the build phase. As `cache = true` the layer is restored from local cache before proceeding to the build phase. For example, a Python distribution could be provided in a cached, build and launch layer. The build phase could verify that the restored cached version of the Python distribution contains Python 3.10 but disregard the patch number of the Python interpreter.
43+
* `cache = true, build = true, launch = true` is an appropriate setting for a layer providing a distribution or runtime such as a Python interpreter or NodeJS runtime.
44+
45+
Other common configurations include
46+
47+
* `cache = true, build = false, launch = true` Allows the same caching behavior as `cache = true, build = true, launch = true`, but the layer is not available to subsequent buildpacks. For example, the build phase can restore a Python distribution disregarding the patch number of the `major.minor.patch` number stored in the metadata. As `build = false` the python interpreter is unavailable to subsequent buildpacks.
48+
* `cache = true, build = true, launch = false` This configuration is useful where a build time dependency is provided. For example, a JDK could be provided as a cached build layer that is not added as a launch layer. Instead, a JRE could be provided as a launch layer in the application image.
49+
* `cache = true, build = false, launch = false` This configuration is particularly useful in layers that download resources. Using a cache-only layer supports allows a buildpack to re-use cached downloads during installation. For example, pip wheels could be downloaded as a cache-only layer and the same buildpack could install the wheels in to a launch layer.
50+
51+
There are other boolean combinations of cache, build and launch. These provide significant flexibility in the caching system. Users of less common caching strategies need a good understanding of the [buildpacks specification on Layer Types](https://github.com/buildpacks/spec/blob/main/buildpack.md#layer-types
52+
).
53+
54+
The flexibility of buildpacks layer options allow fine-grained control over caching. A buildpack may make _content_ level decisions about the validity of a previous layer (as opposed to using the less granular metadata). A buildpack may contribute a launch layer that includes a built application and its dependencies. The same buildpack can also contribute a cache-only layer containing the source dependencies. In subsequent builds the buildpack can detect whether application dependencies have changed. The subset of dependencies that have changed may be updated on the cache layer. Then all dependencies may be restored from the cache layer and the built application is contributed as a new launch layer. In this way we make content-level decisions about the validity of dependencies. In addition, content-level caching strategies can save time and bandwidth by choosing to update only a subset of the cached content.

content/docs/buildpack-author-guide/create-buildpack/caching.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ else
169169
# Determine if there has been a gem dependency change and install new gems to the bundler layer; re-using existing and un-changed gems
170170
echo "---> Installing gems"
171171
mkdir -p "$bundlerlayer"
172-
cat > "$layersdir/bundler.toml" << EOL
172+
cat >> "$layersdir/bundler.toml" << EOL
173173
[metadata]
174174
checksum = "$local_bundler_checksum"
175175
EOL

content/docs/buildpack-author-guide/create-buildpack/detection.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ ERROR: failed to build: executing lifecycle: failed with status code: 51
5050

5151
Notice that `detect` now passes because there is a valid `Gemfile` in the Ruby app at `ruby-sample-app`, but now `build` fails because it is currently written to error out.
5252

53-
You will also notice that `ANALYZING` now appears in the build output. This step is part of the buildpack lifecycle that looks to see if any previous image builds have layers that the buildpack can re-use. We will get into this topic in more detail later.
53+
You will also notice that `RESTORING` now appears in the build output. This step is part of the buildpack lifecycle that looks to see if any previous image builds have layers that the buildpack can re-use. We will get into this topic in more detail later.
5454

5555
<!--+if false+-->
5656
---

content/docs/operator-guide/create-a-builder.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ uri = "samples/buildpacks/hello-processes"
3030
[[buildpacks]]
3131
# Packaged buildpacks to include in builder;
3232
# the "hello-universe" package contains the "hello-world" and "hello-moon" buildpacks
33-
image = "cnbs/sample-package:hello-universe"
33+
uri = "docker://cnbs/sample-package:hello-universe"
3434

3535
# Order used for detection
3636
[[order]]

katacoda/scenarios/buildpack-author-guide/caching.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ else
165165
# Determine if there has been a gem dependency change and install new gems to the bundler layer; re-using existing and un-changed gems
166166
echo "---> Installing gems"
167167
mkdir -p "$bundlerlayer"
168-
cat > "$layersdir/bundler.toml" << EOL
168+
cat >> "$layersdir/bundler.toml" << EOL
169169
[metadata]
170170
checksum = "$local_bundler_checksum"
171171
EOL

0 commit comments

Comments
 (0)