terraform-provider-docker
terraform-provider-docker copied to clipboard
Support for BUILDKIT Inline Cache
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