Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit13efeb6

Browse files
feat(build step): add --cache-to (codefresh-io#1114)
* feat(build step): add --cache-to* feat(build step): add --cache-to* feat(build step): add --cache-to* feat(build step): add --cache-to* Update build.md* Update build.md* Update build.md---------Co-authored-by: NimRegev <nima.regev@codefresh.io>
1 parent42040e0 commit13efeb6

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

‎_docs/pipelines/steps/build.md‎

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ step_name:
5050
build_arguments:
5151
- key=value
5252
cache_from:
53-
- owner/image-name:${{CF_BRANCH}}
53+
- owner/image-name:$CF_BRANCH
5454
- owner/image-name:main
55+
cache_to:
56+
- owner/image-name:$CF_BRANCH
5557
target: stage1
5658
no_cache: false
5759
no_cf_cache: false
@@ -94,6 +96,7 @@ The default behavior of the `build` step is defined a
9496
| `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 |
9597
| `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|
9698
| `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 |
97100
| `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 |
98101
| `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 |
99102
|`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:
157160
build_arguments:
158161
- key=value
159162
cache_from:
160-
- owner/image-name:${{CF_BRANCH}}
163+
- owner/image-name:$CF_BRANCH
161164
- owner/image-name:main
165+
cache_to:
166+
- owner/image-name:$CF_BRANCH
162167
target: stage1
163168
no_cache: false
164169
no_cf_cache: false
@@ -314,6 +319,32 @@ steps:
314319

315320
{% endraw %}
316321

322+
### Using `cache_from` and `cache_to` with `buildx`
323+
324+
`codefresh.yml`
325+
{% raw %}
326+
327+
```yaml
328+
version: '1.0'
329+
steps:
330+
BuildMyImage:
331+
title: Building My Docker image
332+
type: build
333+
image_name: my-app-image
334+
dockerfile: my-custom.Dockerfile
335+
tag: 1.0.1
336+
buildx:
337+
builder:
338+
driver: docker-container
339+
cache_from:
340+
- type=registry,ref=my-registry/my-app-image:${{CF_BRANCH}}
341+
- type=registry,ref=my-registry/my-app-image:master
342+
cache_to:
343+
- type=registry,mode=max,oci-mediatypes=true,image-manifest=true,compression=zstd,ref=my-registry/my-app-image:${{CF_BRANCH}}
344+
```
345+
346+
{% endraw %}
347+
317348
### Multi-platform images with `platform` and `buildx`
318349

319350
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.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp