Skip to content

Figure a better builder_cache architecture. #28

@ashpect

Description

@ashpect

Normally, buildkit would persist the cache in var/lib/buildkit inside the container/system you would run it.
In case you run it, let's say on privileged mode as a docker container, it would mount the containerd layer storage and store at that place.
However, our use case dictates buildkit to run as an ephemeral container whenever we want to build an image.
To achieve persistent cache, we need to mount cache somewhere else.

  1. We could use --export-cache and --import-cache flag to point the build to a registry. This is nice but there might be issues with registry rewrites on cache pushing. View the discussion here.
    However, this drastically reduces the build time as base layers would be same nonetheless. The issue arises when I make runtime py node , then runtime node rb then if we try runtime py go, we won't fetch py's cache.
  2. Building metacall has known limited languages, so after initialisation ; we could first run a build with all languages runtime lang1 lang2 ... and simply export this to the registry and then all other subsequent builds, we only import from the registry and do not export to it, preventing rewrites.
  3. If we don't want to do the above as the initialise build time would be higher, we could just once and for all upload the layers to docker hub or some form of hosted repos and not worry about first build at all. Simply importing in your k8s architecture. However, this won't work in an air gapped environment, so keeping 2nd as the fallback seems logical.
  4. We could mount a volume to the registry or any other container and store the layers as artifacts, and just provide the cache path to buildkit. However, would need to check if there are any rewrites happening if any, and if not, is it feasible. Need to experiment and look.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions