# Create this base image once and reuse # docker build -f Dockerfile.base -t my-node-base . # === Dockerfile.base (build once) === # FROM node:18-alpine # RUN apk add --no-cache python3 make g++ vips-dev # WORKDIR /app # === Main Dockerfile (super fast) === FROM my-node-base AS development # Copy package files COPY package.json package-lock.json ./ # Install deps with cache RUN --mount=type=cache,target=/root/.npm \ npm ci --legacy-peer-deps # Copy source COPY . . ENV CI=true PORT=3000 CMD ["npm", "start"] # Build stage FROM development AS build RUN npm run build # Production FROM nginx:alpine COPY --from=build /app/.nginx/nginx.conf /etc/nginx/conf.d/default.conf COPY --from=build /app/build /usr/share/nginx/html ENTRYPOINT ["nginx", "-g", "daemon off;"]