# 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: Use a minimal base image FROM alpine:latest # Copy the build output from the previous stage COPY --from=build-stage /app/build ./build