File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -283,32 +283,38 @@ Here is an example `Dockerfile` which can serve any Node application:
283
283
284
284
` ` ` Dockerfile
285
285
# ---- Build Stage ----
286
- FROM node:22-alpine AS builder
286
+ FROM public.ecr.aws/docker/library/ node:22-alpine AS builder
287
287
288
288
WORKDIR /app
289
289
290
290
# Copy all files
291
291
COPY . .
292
292
293
+ # Install pnpm
294
+ RUN corepack enable && corepack prepare pnpm@latest --activate
295
+
293
296
# Install dependencies
294
- RUN npm install
297
+ RUN pnpm install
295
298
296
299
# Build Next.js app
297
- RUN npm run build
300
+ RUN pnpm run build
298
301
299
302
# ---- Production Stage ----
300
- FROM node:22-alpine AS runner
303
+ FROM public.ecr.aws/docker/library/ node:22-alpine AS runner
301
304
302
305
WORKDIR /app
303
306
304
307
ENV NODE_ENV=production
305
308
309
+ # Install pnpm in production image
310
+ RUN corepack enable && corepack prepare pnpm@latest --activate
311
+
306
312
# Copy only necessary files from builder
307
313
COPY --from=builder /app/ ./
308
314
309
315
EXPOSE 3000
310
316
311
- CMD ["npm", "run ", "start"]
317
+ CMD ["pnpm ", "start"]
312
318
` ` `
313
319
314
320
You might want to add a `.dockerignore` to minimize the context size :
You can’t perform that action at this time.
0 commit comments