Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/build.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 28 additions & 4 deletions .github/workflows/cleanup-after-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ jobs:
with:
aws_account: ${{ vars.AWS_ACCOUNT }}
- name: Cleanup global-functions
run: cd examples/global-functions && pnpm run destroy:ci
run: |
cd examples/global-functions
if [ -f yarn.lock ]; then yarn run destroy:ci;
elif [ -f package-lock.json ]; then npm run destroy:ci;
elif [ -f pnpm-lock.yaml ]; then pnpm run destroy:ci;
else echo "Lockfile not found." && exit 1;
fi
continue-on-error: true
cleanup-global-containers:
needs: check-if-should-run
Expand All @@ -34,7 +40,13 @@ jobs:
with:
aws_account: ${{ vars.AWS_ACCOUNT }}
- name: Cleanup global-containers
run: cd examples/global-containers && pnpm run destroy:ci
run: |
cd examples/global-containers
if [ -f yarn.lock ]; then yarn run destroy:ci;
elif [ -f package-lock.json ]; then npm run destroy:ci;
elif [ -f pnpm-lock.yaml ]; then pnpm run destroy:ci;
else echo "Lockfile not found." && exit 1;
fi
continue-on-error: true
cleanup-regional-containers:
needs: check-if-should-run
Expand All @@ -47,7 +59,13 @@ jobs:
with:
aws_account: ${{ vars.AWS_ACCOUNT }}
- name: Cleanup regional-containers
run: cd examples/regional-containers && pnpm run destroy:ci
run: |
cd examples/regional-containers
if [ -f yarn.lock ]; then yarn run destroy:ci;
elif [ -f package-lock.json ]; then npm run destroy:ci;
elif [ -f pnpm-lock.yaml ]; then pnpm run destroy:ci;
else echo "Lockfile not found." && exit 1;
fi
continue-on-error: true
cleanup-regional-functions:
needs: check-if-should-run
Expand All @@ -60,5 +78,11 @@ jobs:
with:
aws_account: ${{ vars.AWS_ACCOUNT }}
- name: Cleanup regional-functions
run: cd examples/regional-function && pnpm run destroy:ci
run: |
cd examples/regional-function
if [ -f yarn.lock ]; then yarn run destroy:ci;
elif [ -f package-lock.json ]; then npm run destroy:ci;
elif [ -f pnpm-lock.yaml ]; then pnpm run destroy:ci;
else echo "Lockfile not found." && exit 1;
fi
continue-on-error: true
37 changes: 37 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build Dockerfiles CI

on:
pull_request:
push:
branches:
- main
workflow_dispatch:

jobs:
build_dockerfiles:
name: Build affected Dockerfiles
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# All Dockerfiles now support npm, yarn, or pnpm based on lockfile detection
- name: Build src/nextjs-build/builder.Dockerfile
uses: docker/build-push-action@v4
with:
context: .
file: src/nextjs-build/builder.Dockerfile
push: false
tags: cdk-nextjs-src-builder:ci

- name: Build examples/turbo/builder.Dockerfile
uses: docker/build-push-action@v4
with:
context: examples/turbo
file: builder.Dockerfile
push: false
tags: cdk-nextjs-turbo-builder:ci
7 changes: 6 additions & 1 deletion .github/workflows/release.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion .github/workflows/upgrade-main.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
<!-- existing content ... -->

## Package Manager Support

All Dockerfiles and CI workflows now automatically detect and use the appropriate package manager (npm, yarn, or pnpm) based on the presence of a lockfile in your project. No manual changes are needed—just ensure your preferred lockfile is present.

Supported lockfiles:
- `yarn.lock` → uses yarn
- `package-lock.json` → uses npm
- `pnpm-lock.yaml` → uses pnpm

If no lockfile is found, the build will fail with an error message.

<!--END STABILITY BANNER-->

Deploy [Next.js](https://nextjs.org/) apps on [AWS](https://aws.amazon.com/) with the [AWS CDK](https://aws.amazon.com/cdk/).

## Features
![Version](https://img.shields.io/github/v/release/cdklabs/cdk-nextjs)
[![npm version](https://img.shields.io/npm/v/cdk-nextjs.svg?style=flat-square)](https://www.npmjs.org/package/cdk-nextjs)
![License](https://img.shields.io/github/license/cdklabs/cdk-nextjs)
Expand Down
8 changes: 7 additions & 1 deletion examples/turbo/builder.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ FROM public.ecr.aws/docker/library/node:22-alpine
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY ./json/ ./cdk-nextjs-cache-handler.cjs ./
RUN npm install -g corepack@latest && corepack enable pnpm && pnpm install --frozen-lockfile
# Install dependencies based on the preferred package manager
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then npm install -g pnpm@latest && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi
COPY ./full/ ./
ARG BUILD_COMMAND
ARG RELATIVE_PATH_TO_PACKAGE
Expand Down
1 change: 1 addition & 0 deletions examples/turbo/global-functions.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#checkov:skip=CKV_DOCKER_2: healthcheck run by AWS Lambda Web Adapter
#checkov:skip=CKV_DOCKER_7: latest tag is ok to use for local builder container
# Package manager logic is handled in builder.Dockerfile (supports npm, yarn, pnpm)
# Keep up to date with: https://github.com/cdklabs/cdk-nextjs/blob/main/src/nextjs-build/global-functions.Dockerfile
ARG BUILDER_IMAGE_ALIAS=cdk-nextjs/builder:latest
FROM $BUILDER_IMAGE_ALIAS AS builder
Expand Down
Loading
Loading