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

Improve docker build time in CI environment #1748

Closed
jogold opened this issue Feb 12, 2019 · 0 comments · Fixed by #1776
Closed

Improve docker build time in CI environment #1748

jogold opened this issue Feb 12, 2019 · 0 comments · Fixed by #1776
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container feature-request A feature should be added or improved. package/tools Related to AWS CDK Tools or CLI

Comments

@jogold
Copy link
Contributor

jogold commented Feb 12, 2019

Hello,

In a CI environment where no layer cache are available, docker builds of ECS tasks can take a very long time.

A classic solution for this is to pull first the latest image from the registry and use it as an input for the --cache-from argument of docker build (see here aws/aws-codebuild-docker-images#26 (comment) and https://medium.com/@gajus/making-docker-in-docker-builds-x2-faster-using-docker-cache-from-option-c01febd8ef84).

This implies the following changes in prepareContainerAsset:

  • In addition to tagging the image with the calculateImageFingerprint, tag with latest
  • When in CI (detected by something like process.env.CI) try to pull latest first and then build with --cache-from

(toolkitInfo.prepareEcrRepository should also be refactored/splitted in order to get the repostoryUri sooner/without having to pass a tag)

I would be interested to have aws-cdk's team opinion on this.

@rix0rrr rix0rrr added feature-request A feature should be added or improved. package/tools Related to AWS CDK Tools or CLI @aws-cdk/aws-ecs Related to Amazon Elastic Container labels Feb 14, 2019
jogold added a commit to jogold/aws-cdk that referenced this issue Feb 15, 2019
When running in CI, try to pull the latest image first and use it as cache
for the build. CI is detected by the presence of the `CI` environment variable.

Closes aws#1748
rix0rrr pushed a commit that referenced this issue Feb 21, 2019
When running in CI, try to pull the latest image first and use it as cache
for the build. CI is detected by the presence of the `CI` environment variable.

Closes #1748
eladb pushed a commit that referenced this issue Feb 26, 2019
When running in CI, try to pull the latest image first and use it as cache
for the build. CI is detected by the presence of the `CI` environment variable.

Closes #1748
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container feature-request A feature should be added or improved. package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants