Skip to content

(ecr-assets): image with variable buildArgs being rebuilt every time #15936

@amirfireeye

Description

@amirfireeye

#5705 made DockerImageAsset generate the asset hash based on, among other things, the buildArgs argument. This means that if build arg is used for anything dynamic the image will be rebuilt for every synth.

Can we have another argument allowing to control the hashing of buildArgs? Maybe hashBuildArgs that defaults to true?

Use Case

  • We pass a CodeArtifact token as a build argument so we can download private packages while building the image.
  • The official Docker documentation gives HTTP proxy as an example of a build argument. They say:
  • Users want to specify variables differently depending on which host they build an image on.

When CDK keeps hashing these build-machine specific arguments, it keeps generating new assets even though the intention is to have the same hash across build machines.

Proposed Solution

hashBuildArgs argument that defaults to true to maintain the current behavior. It can then be used here.

if (props.hashBuildArgs && props.buildArgs) { extraHash.buildArgs = props.buildArgs; }

Other

The PR that made this caused this issue is #5705

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

This is a 🚀 Feature Request

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/assetsRelated to the @aws-cdk/assets package@aws-cdk/aws-ecr-assetsRelated to AWS CDK Docker Image Assetseffort/smallSmall work item – less than a day of effortfeature-requestA feature should be added or improved.good first issueRelated to contributions. See CONTRIBUTING.mdp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions