Skip to content

Commit

Permalink
feat(docker): changing docker in two stages
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman Agarwal authored and Aman Agarwal committed Nov 28, 2023
1 parent 0253611 commit 566cf47
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Use the official Node.js 14 image as a base
FROM node:18-alpine
# Stage 1: Build Stage
FROM node:18-alpine AS build

# Set the working directory inside the container
WORKDIR /usr/src/app
WORKDIR /app

# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
Expand All @@ -16,7 +16,20 @@ COPY . .
# Build the Next.js app
RUN npm run build

COPY /.next/standalone ./
# Stage 2: Runtime Stage
FROM node:18-alpine

# Set the working directory inside the container
WORKDIR /app

# Copy only necessary files from the build stage
ENV NODE_ENV production

COPY --from=build /app/next.config.js ./next.config.js
COPY --from=build /app/public ./public
COPY --from=build /app/package.json ./package.json
COPY --from=build /app/.next/standalone ./
COPY --from=build /app/.next/static ./.next/static

# Expose the desired port
EXPOSE 3000
Expand Down

0 comments on commit 566cf47

Please sign in to comment.