vercel / turborepo

Build system optimized for JavaScript and TypeScript, written in Rust
https://turbo.build/repo/docs
MIT License
26.22k stars 1.81k forks source link

Add ability to cache docker images #4932

Closed jakeleventhal closed 8 months ago

jakeleventhal commented 1 year ago

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

chris-olszewski commented 1 year ago

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.

jakeleventhal commented 1 year ago

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 turbo image which builds a docker image, and specify the image as an output (similar to how bazel works). then in ci, my remote cache should be able to recognize a cache hit, and download the docker artifact as an output

mehulkar commented 1 year ago

@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?

jakeleventhal commented 1 year ago

how exactly would you even specify a docker image output?

mehulkar commented 1 year ago

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?

jakeleventhal commented 1 year ago

They get saved to a ~/.docker directory

mehulkar commented 1 year ago

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!

jakeleventhal commented 1 year ago

There isn't a way to specify this unfortunately.