aws-amplify / aws-amplify/amplify-hosting
Adding caching options to amplify.yml causes "Build container ran out of memory"
- Dominant language
- Dockerfile
- Stars
- 481
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have removed any sensitive information from my code snippets and submission.
### Amplify Hosting feature
Deployments
### Is your feature request related to a problem? Please describe:
When I add the following to my `amplify.yaml`, my builds begin to fail with the error message: `Build container ran out of memory`
```
cache:
paths:
- node_modules/**/*
- $(pnpm store path)
```
I can confirm that the build logs show our code builds successfully, all the way to the end of our build steps...and the failure happens _after_ our frontend is already built and ready to be deployed.
Removing the cache settings returns our build pipelines to a working condition.
We're using pnpm version 9 with workspaces and the following .npmrc settings:
```
shamefully-hoist=true
package-import-method=copy
link-workspace-packages=false
```
Based on information I've found in other issues, I even do the following in our pipeline, in an attempt to side-step memory-related limitations for my builds:
```
commands:
- |
# Set up swap space
echo "Setting up swap space..."
sudo fallocate -l 32G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon -s
echo "Done setting up swap space!"
```
### Describe how you'd like this feature to work
We'd like to benefit from using the cache for faster builds.
Contributor guide
Research direction
Start with the amplify.yml cache paths and the .npmrc settings shown in the issue, then compare build logs from runs with and without caching. Reproduce the pnpm workspace build and identify which cache step triggers the memory failure; done means the configured cache completes without the build container running out of memory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, nodejs
- Domain
- ci-cd, cloud, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100