[RFC] Add ability to cache docker images #7352
Replies: 10 comments 1 reply
-
Hi Jake, could you elaborate a little bit more on what you mean by having Turborepo cache docker images? Docker itself already has fairly advanced image caching. |
Beta Was this translation helpful? Give feedback.
-
sure, what im referring to is being able to cache the output of a docker build much in the same way that i would cache any other output in turbo. For instance, i should be able to run a script "image" via |
Beta Was this translation helpful? Give feedback.
-
@jakeleventhal what happens when you do that today? I imagine the artifact size is pretty large, so writing to cache (especially remote cache) could take a while, but turbo shouldn't have an opinion over what the outputs are. If you're running into issues, can you provide a reproduction repo? |
Beta Was this translation helpful? Give feedback.
-
how exactly would you even specify a docker image output? |
Beta Was this translation helpful? Give feedback.
-
sorry, it's been ~a decade since I used docker, does it not create the image on your local disk first? Is it no longer a local directory or file on your filesystem when you create the image? |
Beta Was this translation helpful? Give feedback.
-
They get saved to a ~/.docker directory |
Beta Was this translation helpful? Give feedback.
-
Is it possible to customize that location such that you could put it in the repo location? (I assume that even if that is possible it may interfere with other docker operations). That said, it seems like there are a couple general purpose features here:
Will bring this up with the team! |
Beta Was this translation helpful? Give feedback.
-
There isn't a way to specify this unfortunately. |
Beta Was this translation helpful? Give feedback.
-
We just discussed this amongst the team and we figure out that there is a looooong way away from where we are today and this feature. There's some value that we can see in us automating the things that need to happen around a Docker registry (push this, pull that, tag this, etc.) - but, because of the ground we would need to cover to make it happen, we're not going to be able to prioritize this for now. There are things that we currently have roadmapped that would cover the aforementioned gap (today -> auto-Docker) in indirect ways. If this Discussion garners intense interest, that could change things, but, until then, we don't feel comfortable promising anything around this right now. So, for right now, we'll leave this open for the community to provide input on what they would like to see out of this feature. (If you only want to show that you're interested, please leave a 👍 on the top-level rather than commenting with a P.S. My input: I love the idea of this and wish we could wave a magic wand and make it happen. 😄 |
Beta Was this translation helpful? Give feedback.
-
As a workaround for users in need of a "hydration" process after restoring cached outputs, I managed to change my pipeline in a way that gives me a "hook" in the cache restoration process. What I did to my root "pipeline:" {
- "build": {
- "dependsOn": ["^build"],
- "inputs": ["src/**"],
- "outputs": ["dist/**"]
- },
+ "build:caching": {
+ "dependsOn": ["^build"],
+ "inputs": ["src/**"],
+ "outputs": ["dist/**"]
+ },
+ "build": {
+ "cache": false,
+ "dependsOn": ["build:caching"]
+ }
}
The Let me show how I configured my Maven packages. (I removed a lot of stuff for simplicity) Here's the "scripts": {
"clean": "mvn clean"
"build:caching": "mvn package",
"build": "mvn jar:jar install:install"
}, This is the {
"$schema": "https://turbo.build/schema.json",
"extends": ["//"],
"pipeline": {
"build:caching": {
"outputs": ["**/target/**"]
}
}
} The CPU-bound operation is I also have the Docker use-case, but I didn't manage to experiment with it yet.. I'm assuming there's a way to do a very similar process, though. Hope it helps! |
Beta Was this translation helpful? Give feedback.
-
Which project is this feature idea for?
Turborepo
Describe the feature you'd like to request
Turbo should be able to cache docker images and use those with cache hits.
Describe the solution you'd like
Implement caching with docker images.
Describe alternatives you've considered
N/A
Beta Was this translation helpful? Give feedback.
All reactions