-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
#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