You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _docs/pipelines/steps/build.md
+33-2Lines changed: 33 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,8 +50,10 @@ step_name:
50
50
build_arguments:
51
51
- key=value
52
52
cache_from:
53
-
- owner/image-name:${{CF_BRANCH}}
53
+
- owner/image-name:$CF_BRANCH
54
54
- owner/image-name:main
55
+
cache_to:
56
+
- owner/image-name:$CF_BRANCH
55
57
target: stage1
56
58
no_cache: false
57
59
no_cf_cache: false
@@ -94,6 +96,7 @@ The default behavior of the `build` step is defined a
94
96
| `tag` | The single tag to assign to the built image. To assign multiple tags, use `tags` (see below). <br>The default tag is the name of the branch or revision that is built. | Default |
95
97
| `tags` | Multiple tags to assign to the built image. {::nomarkdown} <br>To assign a single tag, use <code class="highlighter-rouge">tag</code> (see above). <br> This is an array, and should conform to the following syntax:<br><code class="highlighter-rouge">tags:<br>- tag1<br>- tag2<br>- {% raw %}${{CF_BRANCH_TAG_NORMALIZED}}{% endraw %}<br>- tag4</code><br><br>OR<br><code class="highlighter-rouge">tags: [ 'tag1', 'tag2', '{% raw %}${{CF_BRANCH_TAG_NORMALIZED}}'{% endraw %}, 'tag4' ]</code>{:/} |Optional|
96
98
| `cache_from` | The list of cache sources to use as Docker cache when building the image. Every source in the list is passed to the build command using the `--cache-from` flag. See [Docker documentation](https://docs.docker.com/engine/reference/commandline/buildx_build/#cache-from){:target="\_blank"} for more info. | Optional |
99
+
| `cache_to` | The list of external destinations such as container registries to which to export the build cache using the `registry` type. Every cache destination in the list is passed to the build command using the `--cache-to` flag. See [Docker documentation](https://docs.docker.com/engine/reference/commandline/buildx_build/#cache-to){:target="\_blank"} for more info. | Optional |
97
100
| `registry` | The name of the registry to which to push the built image. You can define any registry that is integrated with Codefresh. <br>When not defined, and you have multiple registry contexts, Codefresh uses the one set as the [default registry]({{site.baseurl}}/docs/docker-registries/external-docker-registries/). | Optional |
98
101
| `registry_contexts` | Advanced property for resolving Docker images when [working with multiple registries with the same domain]({{site.baseurl}}/docs/ci-cd-guides/working-with-docker-registries/#working-with-multiple-registries-with-the-same-domain). When defined, pulls the image from the specified context. <br> NOTE: When using `buildx` to build and push multi-platform images, `registry_contexts` cannot be assigned a different registry from the same domain as the target registry defined for `registry`, as Docker does not support being logged in to multiple Docker registries that share the same domain at the same time. | Optional |
99
102
|`disable_push` | Defines if to automatically push the built image to the registry or not. When set to `false`, the default, the image is automatically pushed to the registry.<br>This setting overrides the default behavior set at the account leve. See [Default behavior for buld steps]({{site.baseurl}}/docs/pipelines/configuration/pipeline-settings/#default-behavior-for-build-steps). <br><br>NOTE: Because of [Docker's limitation on loading multi-platform images](https://github.com/docker/buildx/issues/59){:target="\_blank"} to the local Docker instance, unless the built image is pushed as part of the `build` step, you cannot reference the same image in subsequent steps using the {% raw %}`${{build_step_name}}`{% endraw %} variable. | Optional |
@@ -157,8 +160,10 @@ step_name:
157
160
build_arguments:
158
161
- key=value
159
162
cache_from:
160
-
- owner/image-name:${{CF_BRANCH}}
163
+
- owner/image-name:$CF_BRANCH
161
164
- owner/image-name:main
165
+
cache_to:
166
+
- owner/image-name:$CF_BRANCH
162
167
target: stage1
163
168
no_cache: false
164
169
no_cf_cache: false
@@ -314,6 +319,32 @@ steps:
314
319
315
320
{% endraw %}
316
321
322
+
### Using `cache_from` and `cache_to` with `buildx`
### Multi-platform images with `platform` and `buildx`
318
349
319
350
Docker images can support multiple platforms and architectures, meaning that you can create an image once, and reuse the same image on different platforms. Docker automatically selects the image that matches the target OS and architecture.