Repository: vercel/next.js
Pull request: Docker example using bun

### What?

Expanded the `with-docker` example for usage with `bun` and added build instructions to the README.

### Why?

The existing example supports npm, yarn and pnpm, but not bun. 

### How?

- Add a separate Dockerfile.bun placed next to the existing Dockerfile, which is more sensible for the existing solution.
- Dockerfile.bun uses the official oven/bun base image (different runtime/tooling than node:18-alpine), so a separate file should be clearer.
- Existing Docker commands in the README remain unchanged, because Docker still uses the existing Dockerfile by default.
- The bun example can be built with: `docker build -f Dockerfile.bun -t nextjs-docker .`

Related to #78465, #82998



Changed files:
filename: examples/with-docker/Dockerfile.bun
patch: @@ -0,0 +1,54 @@
+# -----------------------------------------------------------------------------
+# This Dockerfile.bun is specifically configured for projects using Bun
+# For npm/pnpm or yarn, refer to the Dockerfile instead
+# -----------------------------------------------------------------------------
+
+# Use Bun's official image
+FROM oven/bun:1 AS base
+
+WORKDIR /app
+
+# Install dependencies with bun
+FROM base AS deps
+COPY package.json bun.lock* ./
+RUN bun install --no-save --frozen-lockfile
+
+# Rebuild the source code only when needed
+FROM base AS builder
+WORKDIR /app
+COPY --from=deps /app/node_modules ./node_modules
+COPY . .
+
+# Next.js collects completely anonymous telemetry data about general usage.
+# Learn more here: https://nextjs.org/telemetry
+# Uncomment the following line in case you want to disable telemetry during the build.
+# ENV NEXT_TELEMETRY_DISABLED=1
+
+RUN bun run build
+
+# Production image, copy all the files and run next
+FROM base AS runner
+WORKDIR /app
+
+# Uncomment the following line in case you want to disable telemetry during runtime.
+# ENV NEXT_TELEMETRY_DISABLED=1
+
+ENV NODE_ENV=production \
+    PORT=3000 \
+    HOSTNAME="0.0.0.0"
+
+RUN addgroup --system --gid 1001 nodejs && \
+    adduser --system --uid 1001 nextjs
+
+COPY --from=builder /app/public ./public
+
+# Automatically leverage output traces to reduce image size
+# https://nextjs.org/docs/advanced-features/output-file-tracing
+COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
+COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
+
+USER nextjs
+
+EXPOSE 3000
+
+CMD ["bun", "./server.js"]

filename: examples/with-docker/README.md
patch: @@ -4,7 +4,7 @@ This examples shows how to use Docker with Next.js based on the [deployment docu
 
 ## How to use
 
-Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), or [pnpm](https://pnpm.io) to bootstrap the example:
+Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init), [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/), [pnpm](https://pnpm.io) or [bun](https://bun.sh/docs/cli/bun-create) to bootstrap the example:
 
 ```bash
 npx create-next-app --example with-docker nextjs-docker
@@ -18,17 +18,28 @@ yarn create next-app --example with-docker nextjs-docker
 pnpm create next-app --example with-docker nextjs-docker
 ```
 
+```bash
+bun create next-app --example with-docker nextjs-docker
+```
+
 ## Using Docker
 
 1. [Install Docker](https://docs.docker.com/get-docker/) on your machine.
-1. Build your container: `docker build -t nextjs-docker .`.
+1. Build your container: 
+    ```bash
+    # For npm, pnpm or yarn
+    docker build -t nextjs-docker .
+    
+    # For bun
+    docker build -f Dockerfile.bun -t nextjs-docker .
+    ```
 1. Run your container: `docker run -p 3000:3000 nextjs-docker`.
 
 You can view your images created with `docker images`.
 
 ### In existing projects
 
-To add support for Docker to an existing project, just copy the [`Dockerfile`](https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile) into the root of the project and add the following to the `next.config.js` file:
+To add Docker support, copy [`Dockerfile`](https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile) to the project root. If using Bun, copy [`Dockerfile.bun`](https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile.bun) instead. Then add the following to next.config.js:
 
 ```js
 // next.config.js
@@ -59,6 +70,8 @@ First, run the development server:
 npm run dev
 # or
 yarn dev
+# or
+bun run dev
 ```
 
 Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.