aws / aws/aws-cdk

NodejsFunction: support buildx and docker-container driver

Open
#29,659 10 comments 2 reactions 0 assignees View on GitHub
@aws-cdk/aws-lambda-nodejs bug feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

NodeJsFunction fail the build during `cdk synth` when using `Python`. I am not providing my own `Dockerfile`. The implementation is in this [repo](https://github.com/awslabs/data-solutions-framework-on-aws/blob/9daa4a90a3bda1678723683d8f8a1a015be3422d/framework/src/processing/lib/spark-runtime/emr-containers/spark-emr-containers-helpers.ts#L84). Below is the log for the failur.

```
#14 [10/10] RUN /sbin/useradd -u 1000 user && chmod 711 /
#14 CACHED
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load

View build details: docker-desktop://dashboard/build/sad_heisenberg/sad_heisenberg0/x0isk1zvr1xmvyt4hs4a2ssit

What's Next?
View a summary of image vulnerabilities and recommendations → docker scout quickview
Bundling asset Stack/InteractiveSessionProvider/OnEventHandlerFunction/Code/Stage...
esbuild cannot run locally. Switching to Docker bundling.
Unable to find image 'cdk-9ee7a11fc0243092baf39e8f9d149e65e683a14e5695909d84aa461dc52a6dab:latest' locally
docker: Error response from daemon: pull access denied for cdk-9ee7a11fc0243092baf39e8f9d149e65e683a14e5695909d84aa461dc52a6dab, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
jsii.errors.JavaScriptError:
@jsii/kernel.RuntimeError: Error: Failed to bundle asset Stack/InteractiveSessionProvider/OnEventHandlerFunction/Code/Stage, bundle output is located at /Users/yyyy/xxxxx/cdk.out/bundling-temp-e33d0e767876b374cc4c34eda8c2c07e1cc83da5543b15d1b7bae574e0fb9f6e-error: Error: docker exited with status 125
--> Command: docker run --rm -u "504:20" -v "/var/folders/ty/hzqp2fl51r9c1146jdmgl0mc0000gr/T/jsii-kernel-srRVBP/node_modules/@cdklabs/aws-data-solutions-framework/lib/processing/lib/spark-runtime/emr-containers/resources/lambdas/managed-endpoint:/asset-input:delegated" -v "/Users/yyyy/xxxxx/emr-cost-tracking-bug-fix/cdk.out/bundling-temp-e33d0e767876b374cc4c34eda8c2c07e1cc83da5543b15d1b7bae574e0fb9f6e:/asset-output:delegated" -w "/" cdk-9ee7a11fc0243092baf39e8f9d149e65e683a14e5695909d84aa461dc52a6dab bash -c "esbuild --bundle \"/asset-input/index.mjs\" --target=node20 --platform=node --outfile=\"/asset-output/index.js\" --external:@aws-sdk/*"
at Kernel._Kernel_ensureSync (/private/var/folders/ty/hzqp2fl51r9c1146jdmgl0mc0000gr/T/tmpva2camqw/lib/program.js:10491:23)
at Kernel.sinvoke (/private/var/folders/ty/hzqp2fl51r9c1146jdmgl0mc0000gr/T/tmpva2camqw/lib/program.js:9876:102)
at KernelHost.processRequest (/private/var/folders/ty/hzqp2fl51r9c1146jdmgl0mc0000gr/T/tmpva2camqw/lib/program.js:11696:36)
at KernelHost.run (/private/var/folders/ty/hzqp2fl51r9c1146jdmgl0mc0000gr/T/tmpva2camqw/lib/program.js:11656:22)
at Immediate._onImmediate (/private/var/folders/ty/hzqp2fl51r9c1146jdmgl0mc0000gr/T/tmpva2camqw/lib/program.js:11657:46)
at process.processImmediate (node:internal/timers:478:21)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/yyyy/xxxxx/app.py", line 10, in
EmrCostTrackingBugFixStack(app, "Stack",
File "/Users/yyyy/xxxxx/.venv/lib/python3.9/site-packages/jsii/_runtime.py", line 118, in __call__
inst = super(JSIIMeta, cast(JSIIMeta, cls)).__call__(*args, **kwargs)
File "/Users/yyyy/xxxxx/emr_cost_tracking_bug_fix/emr_cost_tracking_bug_fix_stack.py", line 17, in __init__
emr_eks_cluster = dsf.processing.SparkEmrContainersRuntime.get_or_create(self,
File "/Users/yyyy/xxxxx/.venv/lib/python3.9/site-packages/cdklabs/aws_data_solutions_framework/processing/__init__.py", line 1551, in get_or_create
return typing.cast("SparkEmrContainersRuntime", jsii.sinvoke(cls, "getOrCreate", [scope, props]))
File "/Users/yyyy/xxxxx/.venv/lib/python3.9/site-packages/jsii/_kernel/__init__.py", line 149, in wrapped
return _recursize_dereference(kernel, fn(kernel, *args, **kwargs))
File "/Users/yyyy/xxxxx/.venv/lib/python3.9/site-packages/jsii/_kernel/__init__.py", line 418, in sinvoke
response = self.provider.sinvoke(
File "/Users/yyyy/xxxxx/.venv/lib/python3.9/site-packages/jsii/_kernel/providers/process.py", line 383, in sinvoke
return self._process.send(request, InvokeResponse)
File "/Users/yyyy/xxxxx/.venv/lib/python3.9/site-packages/jsii/_kernel/providers/process.py", line 342, in send
raise RuntimeError(resp.error) from JavaScriptError(resp.stack)
RuntimeError: Error: Failed to bundle asset Stack/InteractiveSessionProvider/OnEventHandlerFunction/Code/Stage, bundle output is located at /Users/yyyy/xxxxx/cdk.out/bundling-temp-e33d0e767876b374cc4c34eda8c2c07e1cc83da5543b15d1b7bae574e0fb9f6e-error: Error: docker exited with status 125
```

### Expected Behavior

The cdk synth should succeed

### Current Behavior

CDK synth fail

### Reproduction Steps

I can link

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.128.0

### Framework Version

_No response_

### Node.js Version

v20.11.1

### OS

Mac

### Language

Python

### Language Version

3.9.6

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with NodejsFunction's Docker bundling path and the referenced framework/src/processing/lib/spark-runtime/emr-containers/spark-emr-containers-helpers.ts entry point, then reproduce the reported cdk synth failure using the docker-container driver. Done means cdk synth succeeds for the reported Python usage without requiring a user-provided Dockerfile.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, docker, node.js, python, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.