guysoft / CustomPiOS

A Raspberry Pi and other ARM devices distribution builder
GNU General Public License v3.0
509 stars 146 forks source link

Add a persistent /build_cache directory? #137

Open EternityForest opened 3 years ago

EternityForest commented 3 years ago

Just a minor thing, but it could be a major help in some cases. What if we had a directory in the workspace that was mounted at /build_cache, and persisted between builds?

This would let you download very large files within build scripts without wasting bandwidth.

I can make a PR or work on this myself if there is interest!

guysoft commented 3 years ago

Could be done, the question is what are you trying to use it for? In a way you already have this with BASE_APT_CACHE https://github.com/guysoft/CustomPiOS/blob/devel/src/modules/base/config#L60

The code for that happens here: https://github.com/guysoft/CustomPiOS/blob/devel/src/custompios#L115

EternityForest commented 2 years ago

I'm currently using a forked version with just these lines added, and I use it for a lot of things, like automatically fetching things from git repos, and for downloading the .NET runtimes. It's also useful for compiling things. There's no reason to recompile something when not much has changed, I can just do the whole compile right in the /build_cache.

  mkdir -p $BASE_WORKSPACE/build_cache
  mkdir -p $BASE_MOUNT_PATH/build_cache
  mount --bind $BASE_WORKSPACE/build_cache $BASE_MOUNT_PATH/build_cache
guysoft commented 2 years ago

ZynthianOS have a similar thing, what they do is place under the filesystem module what they have built and then unpack it in to the build. I can see how a cache could be helpful, but thinking what kind of commands you would want to run in the build could help. You could have seperate builds steps that use for example custompios_export commands and then move the results in to a filesystem section of a module. The thing with a cache is that it can change during the build, this way you have definitive steps you could run.

Or you could build a base image, then use CustoPiZer which is what OctoPrint and OctoPi-Klipper do.

I can understand how what you do helps you, and it might be helpful to others and worthwhile to put in, I am just not sure of the structure yet and the solutions above are a more structured way to get stuff in to the image.