aws / aws/aws-cdk

aws-lambda-python-alpha: `PythonFunction` requires 4 minutes to build and produces a 3GB Docker image

Open
#32,682 4 comments 0 reactions 0 assignees View on GitHub
@aws-cdk/aws-lambda-python bug effort/medium p3
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

The Docker image for this Lambda function was built on an AMD Ryzen 5 7600X CPU.

The resulting image size of 3GB is highly excessive, especially considering that the final Lambda function deployment package is only 3.6MB.

![image](https://github.com/user-attachments/assets/50c73105-2266-4970-bb0e-b6ef0c35b9b4)

![image](https://github.com/user-attachments/assets/8ad130e0-3f4d-4dca-98ed-2f2e69acfb81)

![image](https://github.com/user-attachments/assets/a186f54b-a092-4c70-903c-674e8250bb14)

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Last Known Working CDK Version

_No response_

### Expected Behavior

See above.

### Current Behavior

See above.

### Reproduction Steps

See above.

### Possible Solution

Refactor the [Dockerfile](https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-lambda-python-alpha/lib/Dockerfile).

### Additional Information/Context

Related issue: #32413

### CDK CLI Version

2.173.3

### Framework Version

_No response_

### Node.js Version

22.12.0

### OS

Ubuntu 24.04.1

### Language

TypeScript

### Language Version

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

The relevant entry point is packages/@aws-cdk/aws-lambda-python-alpha/lib/Dockerfile. Start by reading that Dockerfile and the related issue #32413, then compare its build output with the reported 3.6MB deployment package. Done means the PythonFunction build no longer takes about four minutes or produces a roughly 3GB image while preserving the deployment package.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, docker, dockerfile, python, typescript
Domain
build-system, cloud, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.