aws_lambda: Allow for a script to generate Docker image
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the feature
Add an additional class method to `DockerImageCode` that allows a user to provide a script which produces the Docker image instead of the CDK executing Docker build itself.
### Use Case
I have a monorepo which uses Bazel and it is suboptimal to perform the entire build process of the Lambda image inside of the Dockerfile. Instead, I have Bazel produce the manifest of all of the files that need to be in the image and the Docker build simply copies these files into the image. Due to Bazel's sandboxing and use of symlinks, it is not possible to use the existing Bazel cache inside of a Docker image. As such, if I could use an external script, I would be able to use my existing setup that leverages the Bazel crash and get a much faster build time.
### Proposed Solution
Maybe something like this:
```
DockerImageCode.from_locally_generated_image(fn, *args, **kwargs)
```
where `fn` is in charge of creating the Docker image and returns its repository name/tag?
### Other Information
Right now, I am creating/uploading my images to ECR with external scripting to the CDK. Once something is deployed, it is not too bad, but the initial setup is error-prone.
### Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### CDK version used
latest
### Environment details (OS name and version, etc.)
Ubuntu 22.04
Contributor guide
Research direction
Start by reading the DockerImageCode entry point and tracing how the existing Docker image build is executed. Define the external script contract, including how it creates and returns an image repository name/tag, then add coverage for successful and failing script-driven builds and verify the resulting Lambda image can be deployed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker, typescript
- Domain
- build-system, cloud
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100