(pipelines) Support docker image caching on CodeBuild #11379
Labels
@aws-cdk/aws-ecr-assets
Related to AWS CDK Docker Image Assets
@aws-cdk/pipelines
CDK Pipelines library
effort/medium
Medium work item – several days of effort
feature-request
A feature should be added or improved.
p2
(See also #11956)
Use Case
Building Docker images from scratch can take a long time on CI.
This blog post by AWS suggests we take advantage of image layer caching to skip native dependencies installation and other time consuming tasks.
(Specially in Node, installing dependencies can take several minutes)
#1776 provided the ability to pull the
latest
tag before building an image, and using the--cache-from
parameter to reuse layer caching.However, #5733 removed this ability, as all images are published to a single ECR repository
Proposed Solution
My workflow to make it work is this:
assets-ecr-repository-name
context to theproject_name
, so each project has its own repository. (This is a workaround and may be deprecated in the future)TAG=$(aws ecr describe-images --repository-name project_name --query 'sort_by(imageDetails,& imagePushedAt)[0].imageTags[0]')
docker pull project_name:$TAG
I'm not really sure what is the best way to simplify this process.
Other
#8606 could solve the issue by allowing workarounds with the
--cache-from
option.This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: