Build in one stage with all the tools, then copy only the result into a tiny final image. Smaller images download faster and have fewer things to attack.
FROM node:22-alpine AS build WORKDIR /app COPY package*.json ./ RUN npm ci COPY . . RUN npm run build FROM nginx:alpine COPY --from=build /app/build /usr/share/nginx/html