Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for BUILDKIT Inline Cache #581

Open
i2dcarrasco opened this issue Oct 4, 2023 · 0 comments
Open

Support for BUILDKIT Inline Cache #581

i2dcarrasco opened this issue Oct 4, 2023 · 0 comments

Comments

@i2dcarrasco
Copy link

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

When building with the docker command and the BUILDKIT_INLINE_CACHE=1 build-arg together with the cache-from option, is caching also the multistage intermediate images. This allows to avoid a full build even if the builder compute doesn't have the image locally (the cache-from option alone will trigger also the full build), avoiding also to create a new image in the remote repository every time.

docker build . -t europe-west1-docker.pkg.dev/.../nginx-base:latest --cache-from europe-west1-docker.pkg.dev/.../nginx-base --build-arg BUILDKIT_INLINE_CACHE=1

In the module I don't know if it's ignoring the cache-from option or the build-arg option, but it's not using the cache and is performing a full build. This only happens when the image does not exists locally (for example after a docker image prune -a). I suppose that the cache-from option is working fine, so I think that maybe the problem is the lack of buildkit support or something similar.

New or Affected Resource(s)

  • docker_image

Potential Terraform Configuration

resource "docker_image" "nginx_base" {
  name = format("%s/nginx/nginx-base:latest", module.artifact_registry.artifact_repo_url)
  build {
    context = "./files/src/nginx-base"
    cache_from = [format("%s/nginx/nginx-base", module.artifact_registry.artifact_repo_url)]

    # also tried with build_args
    build_arg = {
      BUILDKIT_INLINE_CACHE : 1
    }

    #tag = [
    #  format("%s/nginx/nginx-base:latest", module.artifact_registry.artifact_repo_url)
    #]
  }

  triggers = {
    dir_sha1 = sha1(join("", [for f in fileset(path.module, "./files/src/nginx-base/*") : filesha1(f)]))
  }
}

References

  • #0000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant