#485  How do you recommend I mount an external voume when using a shell executor?
Closed
Stephen S opened 2 years ago

While building a docker image using a shell executor I may mount a cache folder where most files are locally saved: this would increase building speed. How do you recommend I mount such a folder while processing the build, along with the files that were checked out from the attached repo?

So the process would look like:

  1. checkout attached repo
  2. mount cache volume/directory
  3. Execute the dockerfile
  4. Push the resulting image to registry

1, 3, 4 work perfectly.

Of course I could create a mountpoint but I guess you have a better solution. Artifacts?

Robin Shen commented 2 years ago

In OneDev a build is designed to be fully reproducible. For this purpose, it should only relies on files in git repository and artifacts retrieved via project/job dependencies (can be declared in job definition).

So cache in OneDev is merely used to increase speed. In case cache is not available the build should also work, just slower.

Cache can be defined in more settings of a job, it expects a key, and a relative path to job workspace. This relative path is initially empty, and your build may store intermediate files into this path. Next time when your build starts, the cache will be mounted with intermediate files generated in previous build.

Stephen S commented 2 years ago

Thanks Robin, this is exactly what I was looking for. You might want to create an entry for that feature in the documentation.

Really, OneDev ROCKS!!!

Stephen S commented 2 years ago

The previous recommendation worked perfectly but I want to go a step further. I am building docker images that depend on a "base" image, vsr-bas. So:

  • I created a project for one of the "child" images, vsr-geo
  • I defined its parent as vsr-bas
  • I pull the vsr-bas:latest image from my registry
  • and build the new image from there

Knowing that vsr-geo is a child project of vsr-bas and that vsr-bas has a cache defined, how do I access the same cache from vsr-bas?

Robin Shen commented 2 years ago

Cache with same key will be shared even if they belongs to different project or job . You may use same cache key in vsr-geo as defined in vsr-bas.

On the other hand, if you want project/job specific cache, just enclose project path/job name variable in the cache key.

Robin Shen changed state to 'Closed' 2 years ago
Previous Value Current Value
Open
Closed
issue 1 of 1
Type
Question
Priority
Minor
Assignee
Issue Votes (0)
Watchers (3)
Reference
onedev/server#485
Please wait...
Page is in error, reload to recover