Skip to content

feat!: s3-ddb cache handler replaces efs, run next build on host, use nextjs official adapter#187

Merged
bestickley merged 80 commits intomainfrom
feat-custom-cache-handler-s3-ddb
Mar 11, 2026
Merged

feat!: s3-ddb cache handler replaces efs, run next build on host, use nextjs official adapter#187
bestickley merged 80 commits intomainfrom
feat-custom-cache-handler-s3-ddb

Conversation

@bestickley
Copy link
Copy Markdown
Contributor

@bestickley bestickley commented Jan 12, 2026

Fixes #165, #142, #127, #121, #115

This PR will be released as 0.5.0-beta.1. It will remain beta until next.config.js' experimental.adapterPath is no longer experimental. This PR requires at least Next.js v16.1.1-canary.19 as it relies on Image Custom Cache Handler. While it's not ideal to depend upon experimental or canary features, this aligns with cdk-nextjs' design philosophy of not tampering with Next.js internals and relying on public APIs wherever possible.

  • Use S3 + DynamoDB as Next.js Cache replacing EFS
    • Create NextjsCache
    • Remove NextjsAssetDeployment
    • Fix APP_PAGE cahe kind with ⨯ Error: failed to pipe response error by storing as utf8 instead of base64
    • .next/cdk-nextjs-init-cache - fill with fetch and prerender json values
  • Run next build on host machine, not in container - simplifying build process and reducing build time.
    • buildContext is replaced with buildDirectory
    • Replace sharp with linux musl libvips since host machine is likely diff arch and platform then cloud/runtime
  • Use Next.js Official Adapters to simplify next.config.ts management.
  • NextjsRegionalFunctions now supports streaming (since API GW now supports it)
  • Improve docs by writing caching, pruning, and nextjs build output guide
  • Upgrade examples to Next.js 16
  • Upgrade Node.js to 24 (LTS)
  • Ensure e2e tests passing
  • Explore usage of S3 Directory Buckets (One Zone Express) for lower cost and faster response times for cache bucket. Decided not to use it. See S3 Directory Bucket (One Zone Express) vs Standard Buckets #191

Follow up Work

bestickley and others added 29 commits January 9, 2026 12:32
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@mergify
Copy link
Copy Markdown

mergify bot commented Jan 23, 2026

❌ The current Mergify configuration is invalid

Details
  • Extra inputs are not permitted @ root → pull_request_rules → item 0 → actions → merge → strict
  • Extra inputs are not permitted @ root → pull_request_rules → item 0 → actions → merge → commit_message → title+body

@mergify
Copy link
Copy Markdown

mergify bot commented Jan 23, 2026

❌ The current Mergify configuration is invalid

Details
  • Extra inputs are not permitted @ root → pull_request_rules → item 0 → actions → merge → strict
  • Extra inputs are not permitted @ root → pull_request_rules → item 0 → actions → merge → commit_message → title+body

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@mergify
Copy link
Copy Markdown

mergify bot commented Jan 23, 2026

❌ The current Mergify configuration is invalid

Details
  • Extra inputs are not permitted @ root → pull_request_rules → item 0 → actions → merge → strict
  • Extra inputs are not permitted @ root → pull_request_rules → item 0 → actions → merge → commit_message → title+body

@mergify
Copy link
Copy Markdown

mergify bot commented Jan 24, 2026

❌ The current Mergify configuration is invalid

Details
  • Extra inputs are not permitted @ root → pull_request_rules → item 0 → actions → merge → strict
  • Extra inputs are not permitted @ root → pull_request_rules → item 0 → actions → merge → commit_message → title+body

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@mergify
Copy link
Copy Markdown

mergify bot commented Jan 24, 2026

❌ The current Mergify configuration is invalid

Details
  • Extra inputs are not permitted @ root → pull_request_rules → item 0 → actions → merge → strict
  • Extra inputs are not permitted @ root → pull_request_rules → item 0 → actions → merge → commit_message → title+body

@mergify
Copy link
Copy Markdown

mergify bot commented Jan 24, 2026

❌ The current Mergify configuration is invalid

Details
  • Extra inputs are not permitted @ root → pull_request_rules → item 0 → actions → merge → strict
  • Extra inputs are not permitted @ root → pull_request_rules → item 0 → actions → merge → commit_message → title+body

@LaurenceGA
Copy link
Copy Markdown
Contributor

Hey. Just wondering what's the next step on this PR?

@bestickley
Copy link
Copy Markdown
Contributor Author

Hey Laurence, I've kinda been waiting for Next.js to release 16.2 so canary isn't required for image custom cache handler but it's taken a lot longer for them than I expected :/

@bestickley bestickley merged commit a313d36 into main Mar 11, 2026
18 of 19 checks passed
@bestickley bestickley deleted the feat-custom-cache-handler-s3-ddb branch March 11, 2026 18:19
@LaurenceGA
Copy link
Copy Markdown
Contributor

Update looks good so far, thanks!.

Just wondering if it's possible to pass build args to the new generated functions.Dockerfile?

I was doing this with the global-functions.Dockerfile something like:

ARG SSM_LAYER_IMAGE_URI=<some-default>

FROM $SSM_LAYER_IMAGE_URI AS ssm-layer

That let me pass in different built lambda layers based on env.

@bestickley
Copy link
Copy Markdown
Contributor Author

Update looks good so far, thanks!.

Just wondering if it's possible to pass build args to the new generated functions.Dockerfile?

I was doing this with the global-functions.Dockerfile something like:

ARG SSM_LAYER_IMAGE_URI=<some-default>

FROM $SSM_LAYER_IMAGE_URI AS ssm-layer

That let me pass in different built lambda layers based on env.

Great callout, @LaurenceGA. Sorry I missed this. Need to add override here. Fixed in #213

@LaurenceGA
Copy link
Copy Markdown
Contributor

Awesome! Updated, and with that it all seems to be working well for me 👍
Thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NextjsGlobalFunctions server actions fail when next build --turbopack

3 participants