Skip to content

Commit

Permalink
Merge branch 'main' into consolidate-common-concepts
Browse files Browse the repository at this point in the history
  • Loading branch information
AidanDelaney authored Mar 8, 2024
2 parents 00dad77 + b991642 commit 5d67b2e
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 21 deletions.
52 changes: 31 additions & 21 deletions content/docs/for-app-developers/concepts/base-images/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,46 @@ The **run image** provides the base image for application images.

<!--more-->

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

### Run image mirrors

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

In the following example, assuming a builder configured with the example TOML above, the selected run image will be
`registry.example.com/example/run`.
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,
based on the image name provided.

```bash
$ pack build registry.example.com/example/app
This is to reduce the amount of data transfer required to push the application image to a registry.

#### Example - determining the registry

If the application image name is:

* `registry.example.com/example/app` - the registry is `registry.example.com`
* `example/app` (registry omitted) - Docker Hub is assumed; the registry is `index.docker.io`

#### Example - determining the run image mirror

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):

```toml
[[run.images]]
image = "example/run"
mirrors = ["registry.example.com/example/run"]
```

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

```bash
$ pack build example/app
$ pack build registry.example.com/example/app
```

> For local development, it's often helpful to override the run image mirrors in a builder. For this, the
> `pack config run-image-mirrors` command can be used. This command does not modify the builder, and instead configures the
> local environment.
the selected run image will be `registry.example.com/example/run`.

> For local development, it's often helpful to override the run image mirrors in a builder.
> For this, the `pack config run-image-mirrors` command can be used.
> This command does not modify the builder, and instead configures the local environment.
>
> To see what run images are configured for a builder, the
> `builder inspect` command can be used. `builder inspect` will output built-in and locally-configured run images for
> a given builder, along with other useful information. The order of the run images in the output denotes the order in
> which they will be matched during `build`.
> To see what run images are configured for a builder, `pack builder inspect` can be used.
> `pack builder inspect` will output built-in and locally-configured run images for a given builder, along with other useful information.
> The order of the run images in the output denotes the order in which they will be matched during `build`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
+++
title="Specify export target"
weight=50
+++

Tell `pack` where you want your application image to be saved.

<!--more-->

By default, when you `pack build` an application, the image will be saved to a daemon, such as Docker or [Podman][podman],
and you can view the image using a command such as `docker image ls`.

However, you could also choose to "publish" the application to an OCI registry, such as Docker Hub or Google Artifact Registry,
or even to a local registry, by providing the `pack build --publish` flag.

Or, you could save the image in OCI layout format on disk by providing the `--layout` flag.
See [here][OCI layout] for more information about working with layout images.

## FAQ: What am I using the daemon for?

Buildpacks always need to run in a containerized environment.
Therefore, even when you publish the application image to a registry,
`pack` is still using a daemon under the hood to create the build container(s) where buildpacks run.

The relationship between the build container and the application container can be seen in the diagram below:

![build diagram](/images/build-container-app-container.svg)

[podman]: /docs/for-app-developers/how-to/special-cases/build-on-podman
[OCI layout]: /docs/for-app-developers/how-to/special-cases/export-to-oci-layout
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ image = "cnbs/sample-base-build:jammy"
[run]
[[run.images]]
image = "cnbs/sample-base-run:jammy"
mirrors = ["other-registry.example.com/cnbs/sample-base-run:jammy"]

# Stack (deprecated) used to create the builder
[stack]
id = "io.buildpacks.samples.stacks.jammy"
# This image is used at runtime
run-image = "cnbs/sample-base-run:jammy"
run-image-mirrors = ["other-registry.example.com/cnbs/sample-base-run:jammy"]
# This image is used at build-time
build-image = "cnbs/sample-base-build:jammy"
```
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5d67b2e

Please sign in to comment.