Improve docker file
This commit is contained in:
32
Dockerfile
Normal file
32
Dockerfile
Normal file
@@ -0,0 +1,32 @@
|
||||
# Stage 1: Build
|
||||
FROM node:18-slim AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy dependencies first to cache better
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm install
|
||||
|
||||
# Copy all source code
|
||||
COPY . .
|
||||
|
||||
# Build the Next.js app
|
||||
RUN npm run build
|
||||
|
||||
|
||||
# Stage 2: Run production image
|
||||
FROM node:18-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/package.json /app/package-lock.json ./
|
||||
RUN npm install --omit=dev
|
||||
|
||||
COPY --from=builder /app/.next .next
|
||||
COPY --from=builder /app/public public
|
||||
COPY --from=builder /app/next.config.ts ./
|
||||
COPY --from=builder /app/src src
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["npx", "next", "start"]
|
||||
Reference in New Issue
Block a user