-
Hi, Does anyone know why Actions are built at runtime on every execution without caching? I am observing prolonged build time because of this. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 16 comments
-
GitHub Actions are extremely flexible to allow you to model whatever kind of build semantics you need. On the other hand, this means that there is a large amount of complexity to contend with. Let me start by making sure I understand what problem you’re describing. It sounds like what you’re saying is that when you create a GitHub Action that uses a
Note the What this does is gives a certain amount of flexibility to the Action. For example, the Action that I created to perform the above task uses a Docker image that includes the runtime for the programming language Elixir. You can see that I defined the Docker image to use the latest version of Elixir. This means that every time the Action executes, it automatically updates my Action to use the latest version of Elixir to run on (since it’s only generating documentation, this isn’t a big risk). If I didn’t want that, I could specify that I want it to generate a Docker container using a more specific version of Elixir, for example v1.8 which is currently equivalent to v1.8.2. Or I could instruct it to use a specific old version of Elixir, such as v1.6.3. This means that it wouldn’t automatically update for new versions of the Elixir runtime, but would update if I changed certain things in my lee-dohm/generate-elixir-docs repository, such as the But let’s say that I don’t want my Action to even evaluate the Dockerfile every time the Action runs, because I want the absolute fastest runtime possible. I want a predefined Docker container to be spun up and get right to work. You can have that too! If you create a Docker image and upload it to Docker Hub or another public registry, you can instruct your Action to use that Docker image specifically using the I hope that helps! Let us know if you have more questions. |
Beta Was this translation helpful? Give feedback.
-
Hi @lee-dohm , Thanks for the thorough reply. I can confirm that the previous HCL syntax version of Actions does show “Using cache” when building from a Dockerfile as seen here. However, since upgrading to the yml workflows, it stopped caching, as seen in the lack of “Using cache” here. |
Beta Was this translation helpful? Give feedback.
-
does a solution for the problem exist? as the answer does not really seem to fix the issue? |
Beta Was this translation helpful? Give feedback.
-
@lee-dohmthe docker image steps in my actions don’t seem to be cached. @wei said that this started happening with the transition to yml workflows. |
Beta Was this translation helpful? Give feedback.
-
Same problem here, it does not cache the layers at all, every push is a new build from start |
Beta Was this translation helpful? Give feedback.
-
Also ran into this, my builds reguarly take 6 minutes now because the container image is built from scratch (caching used to work when Actions was in early preview) |
Beta Was this translation helpful? Give feedback.
-
This is really NOT a solution. The solution is to support Docker build cache (layer caching). |
Beta Was this translation helpful? Give feedback.
-
There is a new way of doing this. https://github.com/actions/cache But i cant find a working example of using this action with docker-compose. |
Beta Was this translation helpful? Give feedback.
-
Yeah, I was also checking the same repo. They have built caching for generic store. Not for Docker Layer Caching. |
Beta Was this translation helpful? Give feedback.
-
How to use cahing on Ruby Gems? It always install all gems … |
Beta Was this translation helpful? Give feedback.
-
+1 I know “+1”'s are annoying, but so are “solutions” for questions that are “solved” when they really aren’t. 😛 |
Beta Was this translation helpful? Give feedback.
-
For solve to this probelm, this action is proper to solve this problem. It cache the layers on registry. |
Beta Was this translation helpful? Give feedback.
-
The way actions building works during a workflow run for actions taken from the Github Actions Marketplace seems completely bizarre to me. I mean, when you add a step that uses a marketplace action (at a specific version), the workflow automatically adds an initial step on execution to build that action, from scratch, re-running the Docker compile step every time I build. The vast majority of time spent in my workflows is for building actions from the Marketplace. To me this is completely unexpected behavior and wastes a ton of time. The whole point of the Marketplace is to allow people to reuse actions, so why do we have to build those actions from scratch every single time, with no caching? |
Beta Was this translation helpful? Give feedback.
-
While trying to workaround the PR Secrets (https://github.community/t5/GitHub-Actions/Make-secrets-available-to-builds-of-forks/td-p/30678) problem, had the bright idea of cacheing the credentials in a container. Just a guess, but cacheing can never be enabled because of the security implications discussed in the linked community. Really wish someone would just call this out and close these types of things as ‘By Design’. |
Beta Was this translation helpful? Give feedback.
-
if you’re not too hung up on GitHub hosted runners, you can think about a self hosted runner. Then you have control over your runner’s cache. https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners |
Beta Was this translation helpful? Give feedback.
-
Could you please point out how to use the caching with the self hosted runner? Specifically with docker. |
Beta Was this translation helpful? Give feedback.
GitHub Actions are extremely flexible to allow you to model whatever kind of build semantics you need. On the other hand, this means that there is a large amount of complexity to contend with. Let me start by making sure I understand what problem you’re describing.
It sounds like what you’re saying is that when you create a GitHub Action that uses a
Dockerfile
that is stored in a GitHub repository, when that Action is executed, the Docker container is generated each time. If I’m understanding you correctly, then it is true that theDockerfile
is evaluated each time the Action is executed but that doesn’t mean that it is built from scratch with no caching. For example, here is a sample log …