Skip to content

Improve docker build time in CI environment #1748

@jogold

Description

@jogold

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ecsRelated to Amazon Elastic Containerfeature-requestA feature should be added or improved.package/toolsRelated to AWS CDK Tools or CLI

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions