简体   繁体   English

如何保存 Github Actions docker 图像的构建结果

[英]How can I save the build result of the Github Actions docker image

Is it possible to save the build of the Github action so that it does not download this action the next time, then the problem is that I created an action that collects php with certain settings and everything is in the docker image, it takes about 2 minutes to beat the date image, which is a lot, since in subsequent executions, it makes no sense to rebuild the whole image and use the result of the build of this image.是否可以保存 Github 操作的构建,以便下次它不会下载此操作,那么问题是我创建了一个操作,该操作通过某些设置收集 php 并且所有内容都在 Z05B6053C41A2130AFD6Z imageFC3B16 中分钟来击败日期图像,这很多,因为在随后的执行中,重建整个图像并使用该图像的构建结果是没有意义的。 在此处输入图像描述

Is there some way to cache it or save this docker build of the file somewhere?有没有办法缓存它或将这个 docker 构建的文件保存在某处?

You can use the native caching - GitHub has an action for this: https://github.com/actions/cache .您可以使用本机缓存 - GitHub 对此有一个操作: https://github.com/actions/cache

You'd place this caching step before your build step.您可以将此缓存步骤放在构建步骤之前。

Essentially you'd create a key from a hash of a file (eg a manifest file) or directory.本质上,您将从文件(例如清单文件)或目录的 hash 创建一个密钥。 Then, the Cache action would check if that key matches the key of the cache.然后,缓存操作将检查该键是否与缓存的键匹配。 If it matches, the cache is reloaded.如果匹配,则重新加载缓存。 If it doesn't match, then in your build step, you'd include an if directive with something like steps.build-cache.outputs.cache-hit != 'true' to ensure that the build step only runs if the cache is invalid.如果不匹配,那么在您的构建步骤中,您将包含一个if指令,其中包含类似steps.build-cache.outputs.cache-hit != 'true'内容,以确保构建步骤仅在缓存时运行是无效的。

The docker-layer-caching action is built on actions/cache , and can be used to cache separate build layers of your Docker container. docker-layer-caching操作建立在actions/cache之上,可用于缓存 Docker 容器的单独构建层。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 github 操作中使用私有 docker 图像 - How can I use private docker image in github actions 无法使用 GitHub 操作构建 Docker 映像 - Unable to Build Docker Image Using GitHub Actions 我无法使用 github 操作在 monorepo 中创建 docker 图像 - I can't create a docker image in a monorepo with github actions 如何使用我的“gha”Docker 缓存来加速 Docker 拉取,以及 Docker 在 Github Actions 上的构建? - How can I use my "gha" Docker cache to speed up Docker pull, as well as Docker build on Github Actions? 如何使用 GitHub 操作实现多级 Docker 构建? - How to implement a multistage Docker build with GitHub Actions? 如何在 github 操作中连接到 docker 容器? - How can I connect to a docker container in github actions? 如何使用 Github Actions 以 RSA 密钥作为构建参数构建 docker 镜像 - How to build a docker image with RSA key as build argument using Github Actions GitHub Google Cloud Run 上的 Actions Runner 容器,可以构建 docker 映像 - GitHub Actions Runner Container on Google Cloud Run that can build docker image Github 操作使用 maven 构建 jar 并用于 docker 镜像构建 - Github actions build jar with maven and use for docker image building Github 操作:推送 gradle 任务构建的 docker 映像 - Github Actions: Push docker image build by gradle task
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM