Skip to content

Commit e7cb3e2

Browse files
author
Natalie Arellano
committed
Improve formatting
Signed-off-by: Natalie Arellano <[email protected]>
1 parent 7da2dd1 commit e7cb3e2

File tree

7 files changed

+194
-97
lines changed

7 files changed

+194
-97
lines changed

content/docs/extension-author-guide/create-extension/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Before we get started, make sure you've got the following installed:
1717

1818
This is a step-by-step tutorial for creating a CNB Image Extension for `curl`.
1919

20-
- [Set up your local environment](/docs/buildpack-author-guide/create-buildpack/setup-local-environment)
20+
- [Set up your local environment](/docs/extension-author-guide/create-extension/setup-local-environment)
2121
- [See a build that requires base image extension in order to succeed](/docs/extension-author-guide/create-extension/why-dockerfiles)
2222
- [Building blocks of an extension](/docs/extension-author-guide/create-extension/building-blocks-extension)
2323
- [Generating a build.Dockerfile for your application](/docs/extension-author-guide/create-extension/build-dockerfile)

content/docs/extension-author-guide/create-extension/build-dockerfile.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,37 @@ weight=404
77

88
#### detect
99

10-
* `cat $workspace/samples/extensions/tree/bin/detect` - the extension always detects (because its exit code is `0`) and provides a dependency
11-
called `tree` by writing to the build plan.
10+
`cat $workspace/samples/extensions/tree/bin/detect` - the extension always detects (because its exit code is `0`) and provides a dependency
11+
called `tree` by writing to the build plan
1212

1313
#### generate
1414

15-
* `cat extensions/tree/bin/generate` - the extension generates a `build.Dockerfile` that installs `tree` on the builder
15+
`cat extensions/tree/bin/generate` - the extension generates a `build.Dockerfile` that installs `tree` on the builder
1616
image
1717

1818
### Re-create our builder with `hello-extensions` updated to require `tree`
1919

20-
* Edit `$workspace/samples/buildpacks/hello-extensions/bin/detect` to uncomment the first set of lines that
20+
1. Edit `$workspace/samples/buildpacks/hello-extensions/bin/detect` to uncomment the first set of lines that
2121
output `[[requires]]` to the build plan
22-
* `$workspace/pack/out/pack builder create $registry_namespace/extensions-builder --config $workspace/samples/builders/alpine/builder.toml --publish`
2322

24-
### See a build in action (run failure case)
23+
2. Create the builder:
2524

26-
* Build the application
27-
image: `$workspace/pack/out/pack build hello-extensions --builder $registry_namespace/extensions-builder --lifecycle-image $LIFECYCLE_IMAGE --verbose`
28-
- you should see:
25+
```
26+
$workspace/pack/out/pack builder create $registry_namespace/extensions-builder \
27+
--config $workspace/samples/builders/alpine/builder.toml \
28+
--publish
29+
```
30+
31+
### Build the application image
32+
33+
```
34+
$workspace/pack/out/pack build hello-extensions \
35+
--builder $registry_namespace/extensions-builder \
36+
--lifecycle-image $LIFECYCLE_IMAGE \
37+
--verbose
38+
```
39+
40+
You should see:
2941

3042
```
3143
[detector] ======== Results ========
@@ -46,10 +58,20 @@ weight=404
4658
Successfully built image hello-extensions
4759
```
4860

49-
* See the image fail to run: `docker run hello-extensions` - you should
50-
see `ERROR: failed to launch: path lookup: exec: "curl": executable file not found in $PATH`.
51-
* What happened: our builder uses run image `cnbs/sample-stack-run:alpine` which does not have `curl` installed, so our
52-
process failed to launch
61+
### See the image fail to run
62+
63+
`docker run hello-extensions`
64+
65+
You should see:
66+
67+
```
68+
ERROR: failed to launch: path lookup: exec: "curl": executable file not found in $PATH
69+
```
70+
71+
What happened: our builder uses run image `cnbs/sample-stack-run:alpine` which does not have `curl` installed, so our
72+
process failed to launch.
73+
74+
Let's take a look at how the `samples/curl` extension fixes the error by switching the run image to another image...
5375

5476
<!--+ if false+-->
5577
---

content/docs/extension-author-guide/create-extension/building-blocks-extension.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ weight=403
55

66
### Examine `tree` extension
77

8-
* `tree $workspace/samples/extensions/tree`
8+
`tree $workspace/samples/extensions/tree`
99

1010
You should see something akin to the following:
1111

content/docs/extension-author-guide/create-extension/run-dockerfile.md

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,51 @@ weight=405
77

88
#### detect
99

10-
* `cat $workspace/samples/extensions/curl/bin/detect` - the extension always detects and provides a dependency
10+
`cat $workspace/samples/extensions/curl/bin/detect` - the extension always detects and provides a dependency
1111
called `curl`
1212

1313
#### generate
1414

15-
* `cat extensions/curl/bin/generate` - the extension generates a `run.Dockerfile` that switches the run image to
15+
`cat extensions/curl/bin/generate` - the extension generates a `run.Dockerfile` that switches the run image to
1616
reference `run-image-curl`
1717

1818
### Build a run image for `curl` extension to use
1919

20-
* `cat $workspace/samples/stacks/alpine/run/curl.Dockerfile` - this is a simple Dockerfile that creates a CNB run image
21-
from the `curl` base image by adding the required CNB user configuration and `io.buildpacks.stack.id` label; the
22-
Dockerfile could come from anywhere, but we include it in the `stacks` directory for convenience
23-
* `docker build --tag run-image-curl --file $workspace/samples/stacks/alpine/run/curl.Dockerfile .`
20+
1. `cat $workspace/samples/stacks/alpine/run/curl.Dockerfile` - this is a simple Dockerfile that creates a CNB run image
21+
from the `curl` base image by adding the required CNB user configuration and `io.buildpacks.stack.id` label
22+
* The Dockerfile could come from anywhere, but we include it in the `stacks` directory for convenience
23+
24+
2. Build the image:
25+
26+
```
27+
docker build \
28+
--file $workspace/samples/stacks/alpine/run/curl.Dockerfile \
29+
--tag run-image-curl .
30+
```
2431

2532
### Re-create our builder with `hello-extensions` updated to require `curl`
2633

27-
* Edit `$workspace/samples/buildpacks/hello-extensions/bin/detect` to uncomment the second set of lines that
34+
1. Edit `$workspace/samples/buildpacks/hello-extensions/bin/detect` to uncomment the second set of lines that
2835
output `[[requires]]` to the build plan
29-
* `$workspace/pack/out/pack builder create $registry_namespace/extensions-builder --config $workspace/samples/builders/alpine/builder.toml --publish`
3036

31-
### See a build in action (success case)
37+
2. Create the builder:
3238

33-
* Build the application
34-
image: `$workspace/pack/out/pack build hello-extensions --builder $registry_namespace/extensions-builder --lifecycle-image $LIFECYCLE_IMAGE --verbose`
35-
- you should see:
39+
```
40+
$workspace/pack/out/pack builder create $registry_namespace/extensions-builder \
41+
--config $workspace/samples/builders/alpine/builder.toml \
42+
--publish
43+
```
44+
45+
### Build the application image
46+
47+
```
48+
$workspace/pack/out/pack build hello-extensions \
49+
--builder $registry_namespace/extensions-builder \
50+
--lifecycle-image $LIFECYCLE_IMAGE \
51+
--verbose
52+
```
53+
54+
You should see:
3655

3756
```
3857
[detector] ======== Results ========
@@ -60,12 +79,20 @@ weight=405
6079
Successfully built image hello-extensions
6180
```
6281

63-
* See the image run successfully: `docker run hello-extensions` - you should see something akin
64-
to `curl 7.85.0-DEV (x86_64-pc-linux-musl)`
65-
* What happened: now that `hello-extensions` requires both `tree` and `curl` in its build plan, both extensions are
82+
### See the image run successfully
83+
84+
`docker run hello-extensions`
85+
86+
You should see something akin to:
87+
88+
```
89+
curl 7.85.0-DEV (x86_64-pc-linux-musl)
90+
```
91+
92+
What happened: now that `hello-extensions` requires both `tree` and `curl` in its build plan, both extensions are
6693
included in the build and provide the needed dependencies for build and launch, respectively
67-
* The `tree` extension installs `tree` at build time, as before
68-
* The `curl` extension switches the run image to `run-image-curl`, which has `curl` installed. Now our `curl` process
94+
* The `tree` extension installs `tree` at build time, as before
95+
* The `curl` extension switches the run image to `run-image-curl`, which has `curl` installed. Now our `curl` process
6996
can succeed!
7097

7198
## What's next?

content/docs/extension-author-guide/create-extension/setup-local-environment.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ the builder image, and switches the run image to an image that has `curl` instal
88

99
### Ensure Docker is running
1010

11-
* `docker version`
11+
`docker version`
1212

1313
If you see output similar to the following, you're good to go! Otherwise, start Docker and check again.
1414

@@ -36,22 +36,29 @@ Server: Docker Engine - Community
3636

3737
### Setup workspace directory
3838

39-
* `workspace=<your preferred workspace directory>`
39+
`workspace=<your preferred workspace directory>`
4040

4141
### Clone the pack repo and build it (FIXME: remove when pack with extensions-phase-2 support is released)
4242

43-
* `cd $workspace`
44-
* `git clone [email protected]:buildpacks/pack.git`
45-
* `cd pack`
46-
* `git checkout extensions-phase-2`
47-
* `make clean build`
43+
`cd $workspace`
44+
45+
`git clone [email protected]:buildpacks/pack.git`
46+
47+
`cd pack`
48+
49+
`git checkout extensions-phase-2`
50+
51+
`make clean build`
4852

4953
### Clone the samples repo
5054

51-
* `cd $workspace`
52-
* `git clone https://github.com/buildpacks/samples.git`
53-
* `cd samples`
54-
* `git checkout extensions-phase-2` (FIXME: remove when `extensions-phase-2` merged)
55+
`cd $workspace`
56+
57+
`git clone https://github.com/buildpacks/samples.git`
58+
59+
`cd samples`
60+
61+
`git checkout extensions-phase-2` (FIXME: remove when `extensions-phase-2` merged)
5562

5663
<!--+ if false +-->
5764
---

content/docs/extension-author-guide/create-extension/why-dockerfiles.md

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,60 @@ Let's see a build that requires base image extension in order to succeed.
99

1010
#### detect
1111

12-
* `cat $workspace/samples/buildpacks/hello-extensions/bin/detect` - the buildpack always detects but doesn't require any
13-
dependencies (as the output build plan is empty)
12+
`cat $workspace/samples/buildpacks/hello-extensions/bin/detect` - the buildpack always detects but doesn't require any
13+
dependencies (as the output build plan is empty)
1414

1515
#### build
1616

17-
* `cat $workspace/samples/buildpacks/hello-extensions/bin/build` - the buildpack tries to use `tree` during the build
18-
phase, and defines a launch process called `curl` that runs `curl --version` at runtime
17+
`cat $workspace/samples/buildpacks/hello-extensions/bin/build` - the buildpack tries to use `tree` during the build
18+
phase, and defines a launch process called `curl` that runs `curl --version` at runtime
1919

2020
### Create a builder with extensions and publish it
2121

22-
* Ensure experimental features are enabled: `$workspace/pack/out/pack config experimental true`
23-
* Download the latest lifecycle tarball from the GitHub release
24-
page: https://github.com/buildpacks/lifecycle/releases/tag/v0.15.0-rc.1 (FIXME: update to 0.15.0 when released)
25-
* Edit `$workspace/samples/builders/alpine/builder.toml` to add the following at the end of the file:
22+
1. Ensure experimental features are enabled: `$workspace/pack/out/pack config experimental true`
23+
24+
2. Download the latest lifecycle tarball from the GitHub release
25+
page: https://github.com/buildpacks/lifecycle/releases/tag/v0.15.0-rc.1 (FIXME: update to 0.15.0 when released)
26+
27+
3. Edit `$workspace/samples/builders/alpine/builder.toml` to add the following at the end of the file:
2628

2729
```
2830
[lifecycle]
2931
uri = <path to lifecycle tarball in previous step>
3032
```
3133

32-
* Ensure you are authenticated with an OCI registry: `docker login` should succeed
33-
* Set your preferred registry namespace: `registry_namespace=<your preferred registry namespace>`
34-
* For now, it is necessary for the builder to be pushed to a registry for `pack build` with image extensions to
35-
succeed
36-
* `$workspace/pack/out/pack builder create $registry_namespace/extensions-builder --config $workspace/samples/builders/alpine/builder.toml --publish`
34+
4. Ensure you are authenticated with an OCI registry: `docker login` should succeed
35+
36+
5. Set your preferred registry namespace: `registry_namespace=<your preferred registry namespace>`
37+
* For now, it is necessary for the builder to be pushed to a registry for builds with image extensions to succeed
38+
39+
6. Create the builder:
40+
41+
```
42+
$workspace/pack/out/pack builder create $registry_namespace/extensions-builder \
43+
--config $workspace/samples/builders/alpine/builder.toml \
44+
--publish
45+
```
3746

3847
### See a build in action (build failure case)
3948

40-
* Ensure experimental features are enabled: `$workspace/pack/out/pack config experimental true`
41-
* Set the lifecycle image for `pack` to use in the untrusted builder workflow (as the trusted workflow that uses
42-
the `creator` is not currently supported): `LIFECYCLE_IMAGE=buildpacksio/lifecycle:0.15.0-rc.1` (FIXME: update to
43-
0.15.0 when released)
44-
* Build the application image (note that the "source" directory is effectively ignored in our
45-
example): `$workspace/pack/out/pack build hello-extensions --builder $registry_namespace/extensions-builder --lifecycle-image $LIFECYCLE_IMAGE --verbose --pull-policy always`
46-
- you should see:
49+
1. Ensure experimental features are enabled: `$workspace/pack/out/pack config experimental true`
50+
51+
2. Set the lifecycle image for `pack` to use in the untrusted builder workflow (as the trusted workflow that uses
52+
the `creator` is not currently supported): `LIFECYCLE_IMAGE=buildpacksio/lifecycle:0.15.0-rc.1` (FIXME: update to
53+
0.15.0 when released)
54+
55+
3. Build the application image (note that the "source" directory is effectively ignored in our example):
56+
57+
```
58+
$workspace/pack/out/pack build hello-extensions \
59+
--builder $registry_namespace/extensions-builder \
60+
--lifecycle-image $LIFECYCLE_IMAGE \
61+
--pull-policy always \
62+
--verbose
63+
```
64+
65+
You should see:
4766

4867
```
4968
[detector] ======== Results ========
@@ -60,11 +79,14 @@ uri = <path to lifecycle tarball in previous step>
6079
[extender] ERROR: failed to build: exit status 127
6180
```
6281

63-
* What happened: our builder doesn't have `tree` installed, so the `hello-extensions` buildpack failed to build (as it
64-
tries to run `tree --version` in its `./bin/build` script). Even though there is a `samples/tree` extension that
65-
passed detection (`pass: samples/[email protected]`), because the `hello-extensions` buildpack didn't require `tree` in the
66-
build plan, the extension was omitted from the detected group (`skip: samples/[email protected] provides unused tree`). Let's
67-
take a look at what the `samples/tree` extension does...
82+
What happened: our builder doesn't have `tree` installed, so the `hello-extensions` buildpack failed to build (as it
83+
tries to run `tree --version` in its `./bin/build` script).
84+
85+
* Even though there is a `samples/tree` extension that passed detection (`pass: samples/[email protected]`), because
86+
the `hello-extensions` buildpack didn't require `tree` in the build plan, the extension was omitted from the detected
87+
group (`skip: samples/[email protected] provides unused tree`).
88+
89+
Let's take a look at how the `samples/tree` extension installs `tree` on the builder image...
6890

6991
<!--+ if false+-->
7092
---

0 commit comments

Comments
 (0)