Skip to content

Commit

Permalink
Update docs to use vim sample instead of tree
Browse files Browse the repository at this point in the history
Signed-off-by: Natalie Arellano <narellano@vmware.com>
  • Loading branch information
natalieparellano committed Jul 25, 2023
1 parent ab71153 commit c0dd6c5
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 56 deletions.
28 changes: 14 additions & 14 deletions content/docs/extension-guide/create-extension/build-dockerfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,36 @@ aliases = [
Builder images can be kept lean if image extensions are used to dynamically install the needed dependencies
for the current application.

### Examine `tree` extension
### Examine `vim` extension

#### detect

<!-- test:exec -->
```bash
cat $PWD/samples/extensions/tree/bin/detect
cat $PWD/samples/extensions/vim/bin/detect
```

The extension always detects (because its exit code is `0`) and provides a dependency called `tree` by writing to the build plan.
The extension always detects (because its exit code is `0`) and provides a dependency called `vim` by writing to the build plan.

#### generate

<!-- test:exec -->
```bash
cat $PWD/samples/extensions/tree/bin/generate
cat $PWD/samples/extensions/vim/bin/generate
```

The extension generates a `build.Dockerfile` that installs `tree` on the builder image.
The extension generates a `build.Dockerfile` that installs `vim` on the builder image.

### Configure the `hello-extensions` buildpack to require `tree`
### Configure the `hello-extensions` buildpack to require `vim`

Set the `BP_REQUIRES` build-time environment variable to configure the `hello-extensions` buildpack to require `tree` (review the `./bin/detect` script to see why this works).
Set the `BP_REQUIRES` build-time environment variable to configure the `hello-extensions` buildpack to require `vim` (review the `./bin/detect` script to see why this works).

<!-- test:exec -->
```
pack build hello-extensions \
--builder localhost:5000/extensions-builder \
--env BP_EXT_DEMO=1 \
--env BP_REQUIRES=tree \
--env BP_REQUIRES=vim \
--network host \
--path $PWD/samples/apps/java-maven \
--pull-policy always \
Expand All @@ -54,24 +54,24 @@ You should see:
```
...
[detector] ======== Results ========
[detector] pass: samples/tree@0.0.1
[detector] pass: samples/vim@0.0.1
[detector] pass: samples/curl@0.0.1
[detector] pass: samples/cowsay@0.0.1
[detector] pass: samples/hello-extensions@0.0.1
[detector] Resolving plan... (try #1)
[detector] skip: samples/curl@0.0.1 provides unused curl
[detector] skip: samples/cowsay@0.0.1 provides unused cowsay
[detector] 2 of 4 buildpacks participating
[detector] samples/tree 0.0.1
[detector] samples/vim 0.0.1
[detector] samples/hello-extensions 0.0.1
[detector] Running generate for extension samples/tree@0.0.1
[detector] Running generate for extension samples/vim@0.0.1
...
[extender (build)] Found build Dockerfile for extension 'samples/tree'
[extender (build)] Applying the Dockerfile at /layers/generated/build/samples_tree/Dockerfile...
[extender (build)] Found build Dockerfile for extension 'samples/vim'
[extender (build)] Applying the Dockerfile at /layers/generated/build/samples_vim/Dockerfile...
...
[extender (build)] Running build command
[extender (build)] ---> Hello Extensions Buildpack
[extender (build)] tree v1.8.0 (c) 1996 - 2018 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro
[extender (build)] VIM - Vi IMproved 9.0 (2022 Jun 28, compiled May 19 2023 16:28:36)
...
Successfully built image hello-extensions
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ aliases = [

<!-- test:suite=dockerfiles;weight=3 -->

### Examine `tree` extension
### Examine `vim` extension

<!-- test:exec -->
```bash
tree $PWD/samples/extensions/tree
tree $PWD/samples/extensions/vim
```

(That's right, we're using the very tool we will later be installing!) You should see something akin to the following:
You should see something akin to the following:

```
.
Expand Down Expand Up @@ -44,7 +44,7 @@ tree $PWD/samples/extensions/tree
the [spec](https://github.com/buildpacks/spec/blob/buildpack/main/image_extension.md)
for further details.

We'll take a closer look at the executables for the `tree` extension in the next step.
We'll take a closer look at the executables for the `vim` extension in the next step.

<!--+ if false+-->
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ docker push localhost:5000/run-image-curl

### Configure the `hello-extensions` buildpack to require `cowsay`

Set the `BP_REQUIRES` build-time environment variable to configure the `hello-extensions` buildpack to require both `tree` and `curl` (review the `./bin/detect` script to see why this works).
Set the `BP_REQUIRES` build-time environment variable to configure the `hello-extensions` buildpack to require both `vim` and `curl` (review the `./bin/detect` script to see why this works).

<!-- test:exec -->
```bash
pack build hello-extensions \
--builder localhost:5000/extensions-builder \
--env BP_EXT_DEMO=1 \
--env BP_REQUIRES=tree,curl,cowsay \
--env BP_REQUIRES=vim,curl,cowsay \
--path $PWD/samples/apps/java-maven \
--pull-policy always \
--network host \
Expand All @@ -61,25 +61,25 @@ You should see:
```
...
[detector] ======== Results ========
[detector] pass: samples/tree@0.0.1
[detector] pass: samples/vim@0.0.1
[detector] pass: samples/curl@0.0.1
[detector] pass: samples/cowsay@0.0.1
[detector] pass: samples/hello-extensions@0.0.1
[detector] Resolving plan... (try #1)
[detector] samples/tree 0.0.1
[detector] samples/vim 0.0.1
[detector] samples/curl 0.0.1
[detector] samples/cowsay 0.0.1
[detector] samples/hello-extensions 0.0.1
[detector] Running generate for extension samples/tree@0.0.1
[detector] Running generate for extension samples/vim@0.0.1
...
[detector] Running generate for extension samples/curl@0.0.1
...
[detector] Running generate for extension samples/cowsay@0.0.1
...
[detector] Found a run.Dockerfile from extension 'samples/curl' setting run image to 'localhost:5000/run-image-curl'
...
[extender (build)] Found build Dockerfile for extension 'samples/tree'
[extender (build)] Applying Dockerfile at /layers/generated/build/samples_tree/Dockerfile...
[extender (build)] Found build Dockerfile for extension 'samples/vim'
[extender (build)] Applying Dockerfile at /layers/generated/build/samples_vim/Dockerfile...
[extender (run)] Found run Dockerfile for extension 'samples/curl'
[extender (run)] Found run Dockerfile for extension 'samples/cowsay'
[extender (run)] Applying Dockerfile at /layers/generated/run/samples_curl/Dockerfile...
Expand All @@ -88,7 +88,7 @@ You should see:
...
[extender (build)] Running build command
[extender (build)] ---> Hello Extensions Buildpack
[extender (build)] tree v1.8.0 (c) 1996 - 2018 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro
[extender (build)] VIM - Vi IMproved 9.0 (2022 Jun 28, compiled May 19 2023 16:28:36)
...
Successfully built image hello-extensions
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,20 @@ Build the run image:
docker build \
--file $PWD/samples/stacks/alpine/run/curl.Dockerfile \
--tag localhost:5000/run-image-curl .

docker push localhost:5000/run-image-curl
```

### Configure the `hello-extensions` buildpack to require `curl`

Set the `BP_REQUIRES` build-time environment variable to configure the `hello-extensions` buildpack to require both `tree` and `curl` (review the `./bin/detect` script to see why this works).
Set the `BP_REQUIRES` build-time environment variable to configure the `hello-extensions` buildpack to require both `vim` and `curl` (review the `./bin/detect` script to see why this works).

<!-- test:exec -->
```bash
pack build hello-extensions \
--builder localhost:5000/extensions-builder \
--env BP_EXT_DEMO=1 \
--env BP_REQUIRES=tree,curl \
--env BP_REQUIRES=vim,curl \
--path $PWD/samples/apps/java-maven \
--pull-policy always \
--network host \
Expand All @@ -74,29 +76,29 @@ You should see:

```
[detector] ======== Results ========
[detector] pass: samples/tree@0.0.1
[detector] pass: samples/vim@0.0.1
[detector] pass: samples/curl@0.0.1
[detector] pass: samples/cowsay@0.0.1
[detector] pass: samples/hello-extensions@0.0.1
[detector] Resolving plan... (try #1)
[detector] skip: samples/cowsay@0.0.1 provides unused cowsay
[detector] 3 of 4 buildpacks participating
[detector] samples/tree 0.0.1
[detector] samples/vim 0.0.1
[detector] samples/curl 0.0.1
[detector] samples/hello-extensions 0.0.1
[detector] Running generate for extension samples/tree@0.0.1
[detector] Running generate for extension samples/vim@0.0.1
...
[detector] Running generate for extension samples/curl@0.0.1
...
[detector] Checking for new run image
[detector] Found a run.Dockerfile from extension 'samples/curl' setting run image to 'localhost:5000/run-image-curl'
...
[extender (build)] Found build Dockerfile for extension 'samples/tree'
[extender (build)] Applying the Dockerfile at /layers/generated/build/samples_tree/Dockerfile...
[extender (build)] Found build Dockerfile for extension 'samples/vim'
[extender (build)] Applying the Dockerfile at /layers/generated/build/samples_vim/Dockerfile...
...
[extender (build)] Running build command
[extender (build)] ---> Hello Extensions Buildpack
[extender (build)] tree v1.8.0 (c) 1996 - 2018 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro
[extender (build)] VIM - Vi IMproved 9.0 (2022 Jun 28, compiled May 19 2023 16:28:36)
...
Successfully built image hello-extensions
```
Expand All @@ -114,9 +116,9 @@ You should see something akin to:
curl 7.85.0-DEV (x86_64-pc-linux-musl) ... more stuff here ...
```

What happened: now that `hello-extensions` requires both `tree` and `curl` in its build plan, both extensions are
What happened: now that `hello-extensions` requires both `vim` and `curl` in its build plan, both extensions are
included in the build and provide the needed dependencies for build and launch, respectively
* The `tree` extension installs `tree` at build time, as before
* The `vim` extension installs `vim` at build time, as before
* The `curl` extension switches the run image to `localhost:5000/run-image-curl`, which has `curl` installed

Now our `curl` process can succeed!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ We unset any custom lifecycle image that may have been provided to ensure that t
# FIXME: remove branch when https://github.com/buildpacks/samples/pull/149 is merged
git clone https://github.com/buildpacks/samples.git && \
cd samples && \
git fetch origin runext/update-samples && \
git fetch --all && \
git checkout runext/update-samples && \
cd ..
```
Expand Down
29 changes: 10 additions & 19 deletions content/docs/extension-guide/create-extension/why-dockerfiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ If the `BP_EXT_DEMO` environment variable is set, the buildpack detects (exits w
cat $PWD/samples/buildpacks/hello-extensions/bin/build
```

The buildpack tries to use `tree` at build-time, and defines a launch process called `curl` that runs `curl --version` at runtime.
The buildpack tries to use `vim` at build-time, and defines a launch process called `curl` that runs `curl --version` at runtime.

### Create a builder with extensions and publish it

Expand All @@ -46,15 +46,6 @@ docker run -d --rm -p 5000:5000 registry:2
You can push the builder to any registry of your choice - just ensure that `docker login` succeeds and replace `localhost:5000` in the following examples with your registry namespace -
e.g., `index.docker.io/<username>`.

**Note**: to follow this demo all the way through to the end (including run image extension), you will need a pre-release version of the lifecycle.
* Download the `.tgz` file for your os/arch from the [releases page](https://github.com/buildpacks/lifecycle/releases)
* Add the following lines to `$PWD/samples/builders/alpine/builder.toml`:

```bash
[lifecycle]
uri = <path to .tgz>
```

Create the builder:

<!-- test:exec -->
Expand Down Expand Up @@ -85,31 +76,31 @@ You should see:
```
...
[detector] ======== Results ========
[detector] pass: samples/tree@0.0.1
[detector] pass: samples/vim@0.0.1
[detector] pass: samples/curl@0.0.1
[detector] pass: samples/cowsay@0.0.1
[detector] pass: samples/hello-extensions@0.0.1
[detector] Resolving plan... (try #1)
[detector] skip: samples/tree@0.0.1 provides unused tree
[detector] skip: samples/vim@0.0.1 provides unused vim
[detector] skip: samples/curl@0.0.1 provides unused curl
[detector] skip: samples/cowsay@0.0.1 provides unused cowsay
[detector] 1 of 4 buildpacks participating
[detector] samples/hello-extensions 0.0.1
...
[extender (build)] Running build command
[extender (build)] ---> Hello Extensions Buildpack
[extender (build)] /cnb/buildpacks/samples_hello-extensions/0.0.1/bin/build: line 6: tree: command not found
[extender (build)] /cnb/buildpacks/samples_hello-extensions/0.0.1/bin/build: line 6: vim: command not found
[extender (build)] ERROR: failed to build: exit status 127
```

What happened: our builder doesn't have `tree` installed, so the `hello-extensions` buildpack failed to build (as it
tries to run `tree --version` in its `./bin/build` script).
What happened: our builder doesn't have `vim` installed, so the `hello-extensions` buildpack failed to build (as it
tries to run `vim --version` in its `./bin/build` script).

Even though there is a `samples/tree` extension that passed detection (`pass: samples/tree@0.0.1`), because
the `hello-extensions` buildpack didn't require `tree` in the build plan, the extension was omitted from the detected
group (`skip: samples/tree@0.0.1 provides unused tree`).
Even though there is a `samples/vim` extension that passed detection (`pass: samples/vim@0.0.1`), because
the `hello-extensions` buildpack didn't require `vim` in the build plan, the extension was omitted from the detected
group (`skip: samples/vim@0.0.1 provides unused vim`).

Let's take a look at how the `samples/tree` extension installs `tree` on the builder image...
Let's take a look at how the `samples/vim` extension installs `vim` on the builder image...

<!--+ if false+-->
---
Expand Down

0 comments on commit c0dd6c5

Please sign in to comment.