I'm deploying a Next.js 14 application with AWS Amplify Gen2, but the builds consistently fail with the error: "Build container ran out of memory".
As suggested in the AWS documentation, I removed .next/cache/**/* from the cache.paths section of my amplify.yml file. I also increased the NODE_OPTIONS environment variable to allocate more memory but that doesn't seem to help
Below is my current amplify.yml configuration:
version: 1
backend:
phases:
build:
commands:
- corepack enable
- pnpm install --frozen-lockfile
- pnpm exec ampx pipeline-deploy --branch $AWS_BRANCH --app-id $AWS_APP_ID
frontend:
phases:
build:
commands:
- export NODE_OPTIONS="--max-old-space-size=12288"
- pnpm run build
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*