-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
(aws-ecr-assets): Build and save images during synthesis rather than at deployment #24936
Comments
Thank you for the feedback and the upcoming PR. Can you share a little bit about the proposed solution? |
Would this help alleviate the issue of base images being built multiple times? If I have a Dockerfile with this kind of structure, FROM alpine:latest AS base
# Baseline configuration
FROM base AS container1
# …
FROM base AS container2
# …
|
@pahud I've taken a look at the source code to understand how the CDK handles building docker images. Here's my understanding:
It seems like the most logical solution is to create a some kind of "bridge" construct that looks like The only issue I see with this solution is that direct interactions with the docker CLI are currently not possible. Is there any reason we couldn't make the Please let me know if I'm missing anything or if you have any suggestions on possible solutions here! |
Just now building a deployment using If something is being built after a PR has been approved (and expected to be ready for immediately deploy), that's an anti-pattern, especially for those using a CD tool like CodePipeline. I made a similar comment here |
Another use case is to be able to not have to rewrite the |
We run these during our publish steps in GitHub Actions. - name: Synth
shell: bash
working-directory: ${{ inputs.directory }}
run: |-
npx cdk synth ...
- name: Upload cdk assets to AWS
shell: bash
run: |-
npx cdk-assets publish --path ./<StackName>.assets.json
|
This would be a great benefit for automated/approval workflows. Our automated processes synthesize and save the Ideally, we'd like to configure image build to occur beforehand so that the deployed artifacts never change after they're generated, meaning what is approved is definitely what gets deployed and we don't have unexpected failures at deploy time. We could just avoid using the CDK for managing docker image assets altogether and require that build pipelines build and push docker images separately, but it's a very useful feature we'd like to continue leveraging. |
It would already help a lot if the Even if it did, one would still have to build again for the actual deploy. So building during synth and saving the (compressed) tarballs into |
Surprised to see this behaviour as well, from my own DX it makes sense to build and save image assets at synth time. |
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:
cdk.out/<stack>.assets.json
file and are subject to expiration before the image is ever builtProposed Solution
No response
Other Information
No response
Acknowledgements
CDK version used
latest
Environment details (OS name and version, etc.)
MacOS 12.6
The text was updated successfully, but these errors were encountered: