B
BlueBuild7mo ago
iron

Build Cache for GitLab.com

I am currently using BlueBuild with a GitHub Action that utilizes the GitHub Actions (GHA) build cache. This feature significantly improves my build times, and I’m very pleased with the results. However, I am considering migrating my project to GitLab.com and have noticed that there doesn't seem to be a similar caching feature available on that platform. I believe it might be possible to implement a caching solution akin to the GHA cache using "Inline cache" or "Registry cache" for GitLab.com. Could anyone provide insights on whether such features are available or if there are plans to implement them in the future? Thank you for your assistance!
Solution:
GitHub
chore: Release · blue-build/cli@054c167
BlueBuild's command line program that builds custom Fedora Atomic images based on your recipe.yml - chore: Release · blue-build/cli@054c167
Jump to solution
20 Replies
Luke Skywunker
Luke Skywunker7mo ago
That would be something that I would have to code up. I believe we've already got an issue for it.
Robert
Robert5mo ago
With our project https://gitlab.com/eu-os/workspace-images/eu-os-base-demo we would also benefit from this caching. Buildah got recently the options --layers --cache-from … --cache-to. Man here: https://manpages.ubuntu.com/manpages/plucky/man1/buildah-build.1.html With Gitlab CI, this could look like: podman build -t container-name:$VERSION --layers --cache-to $CI_REGISTRY_IMAGE/cache-image --cache-from $CI_REGISTRY_IMAGE/cache-image -f Containerfile . The cache-image could possibly made configurable. @Luke Skywunker I did not find the issue in the cli repo. If you tell me where it is, I can also add this info to the issue (and track the issue myself). 🙂
Luke Skywunker
Luke Skywunker5mo ago
It looks like we don't have one. I can try to remember to make one later, or you can write it up
Luci • 🍄
Luci • 🍄5mo ago
Could you share this cache stuff? I'd love to use it myself.
Robert
Robert5mo ago
I have created this issue here: https://github.com/blue-build/cli/issues/410
GitHub
feat: support podman/buildah image cache to reach feature parity on...
Hi, following the discussion on Discord, I propose to add to blue-build options to use image caching also on other platforms than Github. One way to do this would be to expose existing caching feat...
Luke Skywunker
Luke Skywunker5mo ago
Cool, thanks for that!
iron
ironOP5mo ago
I've been using a caching strategy similar to this example from the GitLab documentation in other projects, and it works great:
docker buildx build --push -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA \
--cache-to type=registry,ref=$CI_REGISTRY_IMAGE/cache-image,mode=max \
--cache-from type=registry,ref=$CI_REGISTRY_IMAGE/cache-image .
docker buildx build --push -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA \
--cache-to type=registry,ref=$CI_REGISTRY_IMAGE/cache-image,mode=max \
--cache-from type=registry,ref=$CI_REGISTRY_IMAGE/cache-image .
I think we should follow a similar approach to BB_BUILDKIT_CACHE_GHA to support this caching mechanism by adding another if statement in the build_tag_push function in docker_drivers.rs. What do you all think?
Luke Skywunker
Luke Skywunker5mo ago
Yeah that's the plan. Just haven't gotten to it
iron
ironOP4mo ago
Great news! It works perfectly now! For anyone facing similar issues, @gmpinder has resolved issue https://github.com/blue-build/cli/issues/410. Starting from version 0.9.12, you can enable registry caching by setting the BB_CACHE_LAYERS environment variable. Thank you, @gmpinder, for your excellent work!
GitHub
Issues · blue-build/cli
BlueBuild's command line program that builds custom Fedora Atomic images based on your recipe.yml - Issues · blue-build/cli
Luke Skywunker
Luke Skywunker4mo ago
The GitHub action should also include the change. The use_cache option will turn this on You can also use the --cache-layers arg
Robert
Robert4mo ago
Dear @Luke Skywunker , what value does BB_CACHE_LAYERStake? I tried with BB_CACHE_LAYERS: true in my variables dictionary in the gitlab-ci yaml file, but I get now the error: "invalid reference format"
Luke Skywunker
Luke Skywunker4mo ago
It needs to be a string So "true" Gitlab variables in the yaml only except numbers and strings
Luke Skywunker
Luke Skywunker4mo ago
Oh am I not replacing / with _ for tags? Rookie mistake I can get a fix out for that
Robert
Robert4mo ago
I do not follow. For which string such replacement would be due? Can I set this manually while waiting for a fix? Our hackathon starts in 13h 🙈
Luke Skywunker
Luke Skywunker4mo ago
The branch name It will get used for generating tags And / is not allowed in a tag
Robert
Robert4mo ago
ok
Luke Skywunker
Luke Skywunker4mo ago
Yeah I've just gotta add some string replacement logic That's gonna be 4 patches this weekend lol Whatever, gotta make it better
Solution
Luke Skywunker
Luke Skywunker4mo ago
GitHub
chore: Release · blue-build/cli@054c167
BlueBuild's command line program that builds custom Fedora Atomic images based on your recipe.yml - chore: Release · blue-build/cli@054c167
Luke Skywunker
Luke Skywunker4mo ago
@Robert you should be good now btw Good luck on your hackathon!

Did you find this page helpful?