# Stage 1: Install dependencies FROM node:14 AS build-stage WORKDIR /app # Copy package.json and package-lock.json first to leverage caching COPY package*.json ./ # Install dependencies RUN npm install # Copy the rest of your application code COPY .env . COPY . . # Build the application RUN npm run build # Final stage: nothing needed, just to complete the multi-stage FROM scratch # Copy the build output from the previous stage to a directory COPY --from=build-stage /app/build ./build