(aws-ecr-assets): Build and save images during synthesis rather than at deployment
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the feature
Currently, docker images defined in CDK apps are not built at synthesis time, but rather at deployment time.
The CDK should offer a way to build docker images during synthesis and save them as assets using `docker save` so that asset generation happens entirely at synthesis time.
### Use Case
The CDK's build behavior for docker images diverges from the observed behavior of other types of assets (e.g. `aws_lambda.AssetCode`) where the asset's output directory (e.g. `cdk.out/asset.${hash}/`) contains the "final" contents of the asset (which are simply compressed during deployment).
This behavior seems to lead to a couple of undesirable realities/limitations:
* There's no way to verify that a docker image definition will be built successfully until one attempts a deployment
* Docker build arguments (which may contain values with TTLs) are encoded in the `cdk.out/.assets.json` file and are subject to expiration before the image is ever built
* Cloud assemblies are no longer fully portable from system to system. The same docker context (and potentially other things like mounts) need to be available on both the system that synthesized the assembly as well as the one that deploys it
### Proposed Solution
_No response_
### Other Information
_No response_
### Acknowledgements
- [X] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### CDK version used
latest
### Environment details (OS name and version, etc.)
MacOS 12.6
Contributor guide
Research direction
Start by tracing the aws-ecr-assets Docker image flow from synthesis through deployment and identify where the Docker context and build arguments are handled. Done means images are built during synthesis, saved with docker save as assets, and the resulting cloud assembly no longer requires the Docker context at deployment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker, typescript
- Domain
- build-system, cloud
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100