diff --git a/Dockerfile b/Dockerfile index 2032755..f0757ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 ./ @@ -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