Customize asset bundling execution
See original GitHub issueWe should offer a way for users to customize how docker is executed during asset bundling at the app level in order to allow users that can’t use docker to leverage bundling.
Use Case
Asset bundling relies on docker to offer a ubiquitous experience for library consumers (see “why we use docker” below). However, running docker in some environments is a major barrier or even not allowed.
As an escape hatch, we should allow users at the application level to override the way docker is executed so they can still use asset bundling in their systems.
Proposed Solution
Introduce some inversion of control when executing the various docker commands during bundling.
This is something that should be done (only?) at the app level since it’s about the specific synthesis environment and it should not be possible for libraries to override this behavior given their don’t know what the synthesis environment will be.
I wonder if it is sufficient to simply say “docker is in PATH and you are welcome to simply provide your own docker command that does whatever you want as long as it respects the contract.”
Another alternative is to defer to an environment variable such as CDK_DOCKER
if it is defined.
Why we use Docker?
Consider the use case in which an app consumes a third-party library which leverages asset bundling (like NodeJsFunction) under the hood (or even multi-level deep).
This app doesn’t even know that somewhere in their dependency graph, someone wants to bundle a Nodejs library with Parcel, let alone interested in setting up their dev and build environments to include these tools.
Docker offers a way to abstract this completely. Granted - this app will need docker available during synthesis, which I could be a barrier in some environments, but once they have docker, they can use any construct library.
- 👋 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:6 (6 by maintainers)
Top GitHub Comments
@jogold I am going to make this change. I’ll send a PR for a review.
They will just tailor their shim based on the use case. For example, they can explore the source of the docker image in Docker Hub and install those dependencies in their environments. Case by case.