-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
feat(core): BundlingDockerImage
now supports run()
and cp()
utilities
#9728
Conversation
New changes to reflect the following:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this PR is adding a new feature, mark the title as a 'feat' instead of 'chore'
packages/@aws-cdk/aws-lambda/test/integ.from-docker-build.complex.ts
Outdated
Show resolved
Hide resolved
@jogold could spare some cycles to work with @misterjoshua on this? @misterjoshua something with the mental model is not intuitive to me at first glance. I am not sure I fully understand the use case and then the terminology of |
FYI, I plan to fix the conflict and resume work on this PR as soon as I can, but I'm swamped this week. |
@jogold can you take a look? |
What's the status here? |
@eladb I believe @jogold requested some feedback on whether we should consider implementing a different asset type. Overall, I'm not sure whether supporting my use case is out of scope for CDK bundling or the project as a whole, considering that I can handle this in a stage that happens before CDK runs. |
You can also just write some code in your CDK app that prepares the asset directory (in whatever way) and then defines an asset that refers to this directory (no need to use bundling in this case). What's the benefit of using the asset bundling mechanism? Is it just to run |
@eladb Yes, I'd say the benefit lies in the ease of controlling docker to prepare such a directory. Does an API like this make sense? // Build a Docker image
const image = BundlingDockerImage.fromAsset(contextPath, {
// Added in this PR, lets you override the Dockerfile path - very useful for me
file: dockerfilePath,
});
// My use case - copy files out of the image from `imagePath` to `localPath` on this computer via `docker cp`
image.copyOut(imagePath, localPath);
// Or alternatively, run the docker image with options.
image.run(dockerRunOptions); Edit: I've pushed up a POC. It's a much smaller change. :) I'll see about adding an integration test in S3 assets. I ran out of time today. |
77c5e80
to
8485802
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this direction. See some comments
@@ -110,6 +110,7 @@ export class BundlingDockerImage { | |||
|
|||
const dockerArgs: string[] = [ | |||
'build', '-q', | |||
...(options.file ? ['-f', options.file] : []), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vaguely recall this is already supported. Did you rebase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eladb I wiped out my previous branch and started fresh from the master branch today - the old commits were not practical to revert. I used the force to push it over the branch in this PR.
I didn't see pre-existing support for this in master. However, I've got practically the same code in PR #9582, which I believe you've previously reviewed. Maybe it was seen there? Not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's currently supported in cdk-assets
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API of the Docker
class in cdk-assets
looks pretty handy to use. But, both core
and cdk-assets
seem to have minimal dependencies. Any ideas what I should do here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing at this stage, I was just mentioning from where @eladb might have thought that this was already supported.
Not for this PR but at some point it might be interesting to correctly define the "roles" of core
vs cdk-assets
. I think that this was already discussed in another issue about where zipping should occur.
@@ -110,6 +110,7 @@ export class BundlingDockerImage { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jogold does it make sense to rename this to DockerImage
? What's "bundling" about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the docker image used when bundling an asset/accepted in the bundling
options... but I agree that there's nothing specific to bundling in its implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave this for a future change
@eladb I've pushed up changes from your review. It's time to sleep, so I'll check in later. :) |
BundlingDockerImage
now supports run
and cp
methods
BundlingDockerImage
now supports run
and cp
methodsBundlingDockerImage
now supports run()
and cp()
utilities
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor
@eladb I've made your |
I see some merge conflicts have arisen. I'll see what's required and push up a commit. |
@eladb I resolved a conflict due to the new |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
This PR introduces
run()
andcp()
utility methods toBundlingDockerImage
. After building their own Docker images, users can more easily run the image or copy files out of the image to create their own assets without using the bundling mechanism.Possibly closes #9329
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license