Skip to content
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

Customize asset bundling execution #8460

Closed
2 tasks
eladb opened this issue Jun 10, 2020 · 6 comments · Fixed by #8481
Closed
2 tasks

Customize asset bundling execution #8460

eladb opened this issue Jun 10, 2020 · 6 comments · Fixed by #8481

Comments

@eladb
Copy link
Contributor

eladb commented Jun 10, 2020

We 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

@eladb
Copy link
Contributor Author

eladb commented Jun 10, 2020

@jogold what do you think?

@jogold
Copy link
Contributor

jogold commented Jun 10, 2020

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.”

Do you expect docker not to be available in PATH or the bin to have a different name? Do you have examples of "docker compatible" CLIs?

@eladb
Copy link
Contributor Author

eladb commented Jun 10, 2020

Do you expect docker not to be available in PATH or the bin to have a different name? Do you have examples of "docker compatible" CLIs?

The idea is not to replace docker as docker but rather to work around the fact that docker is missing. For example, if I know I want to use the lambda Parcel bundler, I can directly install parcel in my build environment and instead of running the docker command inside a container, I can just run it as is.

@jogold
Copy link
Contributor

jogold commented Jun 10, 2020

OK got it!

The naive approach is to skip docker build (if any) and simply run the command of docker run in the current shell (doesn't work if the command is defined in the container)? How would users "discover" what dependencies they need for this to work outside docker?

@eladb
Copy link
Contributor Author

eladb commented Jun 10, 2020

How would users "discover" what dependencies they need for this to work outside docker?

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.

@eladb
Copy link
Contributor Author

eladb commented Jun 10, 2020

@jogold I am going to make this change. I'll send a PR for a review.

eladb pushed a commit that referenced this issue Jun 10, 2020
In order to support environments in which docker cannot be executed or has a unique location, we added an environment variable `CDK_DOCKER` which is used instead of `docker` if defined.

Resolves #8460
@mergify mergify bot closed this as completed in #8481 Jun 11, 2020
mergify bot pushed a commit that referenced this issue Jun 11, 2020
In order to support environments in which docker cannot be executed or has a unique location, we added an environment variable `CDK_DOCKER` which is used instead of `docker` if defined.

Resolves #8460


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants