Skip to content

Code Pipeline Integration #108

@ericchehata

Description

@ericchehata

Asset Deployment Fails in CodePipeline Due to Missing Docker Image

Describe the issue

I'm using the cdk-nextjs library in a CDK app to deploy a Next.js application. When I synth and deploy locally, everything works as expected. However, when deploying via AWS CodePipeline, the Assets stage fails during asset bundling for the Lambda function.

More specifically, the following steps fail:

  • Nextjs_NextjsAssetsDeployment_Fn_AssetImage
  • Nextjs_NextjsFunctions_Functions_AssetImage

with the error:

#2 [internal] load metadata for docker.io/cdk-nextjs/builder-9266d429429e:latest
#2 ERROR: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed

Expected behavior

The Docker image should be available during the asset deployment stage, or an alternative method should exist to persist or configure the image used by the asset bundling step.

Steps to reproduce

  1. Create a CDK app with NextjsGlobalFunctions from cdk-nextjs
  2. Use a GitHub repository as the source in a CodePipeline
  3. In the build phase, build the cdk app
  4. Attempt to deploy via CodePipeline
  5. Observe the asset stage fail due to missing Docker image

Additional context

From my understanding, the image cdk-nextjs/builder-9266d429429e:latest is built during the CodeBuild phase but not persisted across stages. When the asset deployment step runs, it tries to pull the image from Docker Hub and fails due to lack of permissions or image availability.

Request

Is there a recommended way to:

  • Persist the built Docker image across stages (e.g., push to ECR and reuse)?
  • Override the image used by NextjsGlobalFunctions for asset bundling?
  • Skip the Docker build step if the app is already built in a prior stage?

Any guidance on how to work around this issue in CI/CD (CodePipeline) would be greatly appreciated.

Environment

  • cdk-nextjs version: latest (as of May 2025)
  • AWS CDK version: v2
  • CDK Language: TypeScript
  • CI/CD: AWS CodePipeline

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions