[core] Override default mounts for bundling containers
See original GitHub issueI need a way to overwrite the mounting paths of the bundling containers which handle stuff like npm install
on lambdas before packing and uploading.
https://docs.aws.amazon.com/cdk/api/latest/docs/aws-lambda-readme.html#bundling-asset-code
It would be nice, if there would be an option to provide alternative paths for the mounted host paths.
Use Case
We use VScode for developing in CDK and want to use Devcontainers. With that we can use a preconfigured docker image as dev environment and a new developer doesn’t have to set up CLI and CDK etc. to start working.
It is possible to launch another docker image from inside the devcontainer. https://github.com/microsoft/vscode-dev-containers/tree/master/containers/docker-from-docker
This works, but the used mount paths are wrong. The CDK provides the paths from inside the devcontainer, but this docker-from-docker strategy requires host paths.
Proposed Solution
Extend the BundlingOptions in core (bundling.ts) with a function property, which allows editing which paths are used as default mounts paths for the bundling containers in asset-staging.ts (atm line 168-179).
// Always mount input and output dir
const volumes = [
{
hostPath: this.sourcePath,
containerPath: AssetStaging.BUNDLING_INPUT_DIR,
},
{
hostPath: bundleDir,
containerPath: AssetStaging.BUNDLING_OUTPUT_DIR,
},
...options.volumes ?? [],
];
Other
(I hope, I explained everything in enough detail, this is my first issue for such a big project as the AWS CDK)
- 👋 I may be able to implement this feature request
- ⚠️ This feature might incur a breaking change
This is a 🚀 Feature Request
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
I’m not opposed to
LOCAL_WORKSPACE_FOLDER
. But we would need to know which container path corresponds to the host’sLOCAL_WORKSPACE_FOLDER
. Is that standardized?On another note, why don’t you mount the directories at the same name in both host and container? This is what I generally do and it removes the need for the mapping.
This is what I put in my
docker run
:Which makes it so I can use any directory under
~
, and I generally don’t need other directories anyway.This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.