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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(pipelines) Support docker image caching on CodeBuild #11379

Open
2 tasks
danilofuchs opened this issue Nov 9, 2020 · 4 comments
Open
2 tasks

(pipelines) Support docker image caching on CodeBuild #11379

danilofuchs opened this issue Nov 9, 2020 · 4 comments
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

Comments

@danilofuchs
Copy link
Contributor

danilofuchs commented Nov 9, 2020

(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:

  • Set assets-ecr-repository-name context to the project_name, so each project has its own repository. (This is a workaround and may be deprecated in the future)
  • Before each build, login to ECR on my Codebuild machine
  • Fetch the most recently pushed tag via AWS CLI
    • TAG=$(aws ecr describe-images --repository-name project_name --query 'sort_by(imageDetails,& imagePushedAt)[0].imageTags[0]')
  • Docker Pull this tag
    • docker pull project_name:$TAG
  • Run AWS CDK (will this use the correct layer caching? I'm not sure)

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.

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@danilofuchs danilofuchs added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 9, 2020
@danilofuchs danilofuchs changed the title [cdk] Readd support for using Docker image cache on build [ecr-assets] Readd support for using Docker image cache on build Nov 9, 2020
@github-actions github-actions bot added the @aws-cdk/aws-ecr-assets Related to AWS CDK Docker Image Assets label Nov 9, 2020
@eladb
Copy link
Contributor

eladb commented Dec 8, 2020

@danilofuchs are you using CodeBuild? See the last paragraph in the CDK pipelines design doc: https://github.com/aws/aws-cdk-rfcs/blob/master/text/0049-continuous-delivery.md#publishing

@rix0rrr rix0rrr changed the title [ecr-assets] Readd support for using Docker image cache on build (pipelines) Support docker image caching on CodeBuild Dec 9, 2020
@rix0rrr rix0rrr added @aws-cdk/pipelines CDK Pipelines library effort/medium Medium work item – several days of effort p2 labels Dec 9, 2020
@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Dec 14, 2020
@eladb eladb removed their assignment Feb 25, 2021
@rix0rrr rix0rrr removed their assignment Jun 3, 2021
@shellscape
Copy link

We're not using CodeBuild and deploying a fargate service using @aws-cdk/aws-ecs-patterns and ApplicationLoadBalancedFargateService with DockerImageAsset. Having a "cache from" (and even "cache to") specifier is key to negating very long build times.

@Durgaprasad-Budhwani
Copy link

Any update on this issue?

@alex5207
Copy link

alex5207 commented Jul 7, 2023

Anyone found a good solution to this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

7 participants