#FROM node:18.14.2 as builder1 #WORKDIR /app #ENV NODE_OPTIONS=--openssl-legacy-provider #COPY package*.json ./ #RUN npm install #COPY . . #FROM node:18.14.2 as run1 #WORKDIR /app #COPY package*.json ./ #COPY --from=builder /app/.output /.output #EXPOSE 3000 #CMD [ "npm", "run", "start" ] # Stage 1: Build FROM node:18.14.2 as builder WORKDIR /app # Install only necessary dependencies for building COPY package*.json ./ RUN npm install --only=production # Copy the necessary source files to build your application COPY . . # Build the application # Add any build scripts here. For example, if you're using a framework # like Next.js, you might run `npm run build` here. RUN npx nuxt build # Stage 2: Runtime FROM node:18.14.2-slim as run WORKDIR /app # Copy only necessary files from the builder stage COPY --from=builder /app/package*.json ./ COPY --from=builder /app/node_modules ./node_modules # If you have any build output, copy it here COPY --from=builder /app/.output ./.output # Copy only the production dependencies RUN npm prune --production EXPOSE 3000 CMD [ "npm", "run", "start" ]