aws / aws/aws-cdk

NodejsFunction: can't pull images due to failed to solve with frontend dockerfile.v0

Open
#25,396 5 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-lambda @aws-cdk/aws-lambda-nodejs bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

When building a `NodejsFunction` using the `bundling.forceDockerBundling: true` flag, the docker image cannot be pulled due to `failed to solve with frontend dockerfile.v0: failed to create LLB definition: unexpected status code [manifests latest]: 400 Bad Request`.

### Expected Behavior

The docker image is pulled and the lambda function is bundled properly

### Current Behavior

`cdk diff` results in:

```sh
[+] Building 0.5s (3/3) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 37B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> ERROR [internal] load metadata for public.ecr.aws/sam/build-nodejs16.x:latest 0.4s
------
> [internal] load metadata for public.ecr.aws/sam/build-nodejs16.x:latest:
------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: unexpected status code [manifests latest]: 400 Bad Request
/Users/adam/projects/rome/common/temp/node_modules/.pnpm/aws-cdk-lib@2.43.1_constructs@10.2.9/node_modules/aws-cdk-lib/core/lib/bundling.js:4
stderr: ${proc.stderr?.toString().trim()}`):new Error(`${prog} exited with status ${proc.status}`);return proc}function isSeLinux(){if(process.platform!="linux")return!1;const prog="selinuxenabled",proc=child_process_1.spawnSync(prog,[],{stdio:["pipe",process.stderr,"inherit"]});return proc.error?!1:proc.status==0}
^
Error: docker exited with status 1
at dockerExec (/Users/adam/projects/rome/common/temp/node_modules/.pnpm/aws-cdk-lib@2.43.1_constructs@10.2.9/node_modules/aws-cdk-lib/core/lib/bundling.js:4:45)
at Function.fromBuild (/Users/adam/projects/rome/common/temp/node_modules/.pnpm/aws-cdk-lib@2.43.1_constructs@10.2.9/node_modules/aws-cdk-lib/core/lib/bundling.js:1:3494)
at new Bundling (/Users/adam/projects/rome/common/temp/node_modules/.pnpm/aws-cdk-lib@2.43.1_constructs@10.2.9/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.js:1:1897)
at Function.bundle (/Users/adam/projects/rome/common/temp/node_modules/.pnpm/aws-cdk-lib@2.43.1_constructs@10.2.9/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/bundling.js:1:2733)
at new NodejsFunction (/Users/adam/projects/rome/common/temp/node_modules/.pnpm/aws-cdk-lib@2.43.1_constructs@10.2.9/node_modules/aws-cdk-lib/aws-lambda-nodejs/lib/function.js:1:1229)
at new deviceManagementAPILambda (/Users/adam/projects/rome/services/device-management/lib/device-management-api-lambda.ts:60:23)
at new DeviceManagementStack (/Users/adam/projects/rome/services/device-management/lib/device-management-stack.ts:69:23)
at Object. (/Users/adam/projects/rome/services/device-management/bin/device-management.ts:6:1)
at Module._compile (node:internal/modules/cjs/loader:1196:14)
at Module.m._compile (/usr/local/lib/node_modules/ts-node/src/index.ts:1618:23)

Subprocess exited with error 1
```

### Reproduction Steps

create a lambda function like:

```typescript
new NodejsFunction(this, 'some-function', {
...normalProps,
runtime: Runtime.NODEJS_16_X,
bundling: {
forceDockerBundling: true,
},
});
```

Then run `cdk diff`, or any other `cdk` command that bundles the function

### Possible Solution

From what I can tell from an online search, this has something to do with the image type? I tried ARM_64 and X86_64, but both failed

### Additional Information/Context

OS: Mac OS 13.3.1 (22E261)
CDK Version: 2.43.1 (build c1ebb85)
Docker version 20.10.24, build 297e128

### CDK CLI Version

2.43.1

### Framework Version

_No response_

### Node.js Version

16.x

### OS

Mac OS 13.3.1

### Language

Typescript

### Language Version

5.0.4

### Other information

This was the first stack overflow post when I searched the error: https://stackoverflow.com/questions/68984133/error-failed-to-solve-with-frontend-dockerfile-v0-failed-to-create-llb-defini

Contributor guide

Open the contributing guide

Research direction

Start with the NodejsFunction bundling path and the forceDockerBundling reproduction, then run cdk diff using the documented runtime and Docker versions. Compare the Docker image pull failure and generated build definition with the expected successful Lambda bundle; done means the image is pulled and the function bundles without the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, docker, typescript
Domain
build-system, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.