File size: 884 Bytes
eec371a f4d820d eec371a 8e12f8b eec371a 8e12f8b eec371a 8e12f8b eec371a 9911620 f4d820d 9911620 164fe40 9911620 164fe40 9911620 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# Use the official Node.js image from Docker Hub
FROM node:18 AS build
# Set the working directory
WORKDIR /usr/src/app
# Copy package.json and package-lock.json for installing dependencies
COPY package.json package-lock.json ./
# Install dependencies
RUN npm install
# Copy the entire project
COPY . .
# Build the project
RUN npm run build
# Use a smaller image for the production environment
FROM node:18-alpine
# Set environment to production
ENV NODE_ENV production
# Set the working directory
WORKDIR /usr/src/app
# Copy from the "build" stage
COPY --from=build /usr/src/app/.next ./.next
COPY --from=build /usr/src/app/package.json ./package.json
COPY --from=build /usr/src/app/package-lock.json ./package-lock.json
# Install only production dependencies
RUN npm install --production
EXPOSE 3000
ENV PORT 3000
# Command to run the application
CMD ["npm", "start"]
|