This way make sure npm install layer is cached . It is rebuilt only when a new package gets added.
npm install
FROM node:22-alpine WORKDIR /app COPY package* . RUN npm install COPY . . npm run build EXPOSE 3000 CMD["node","dist/index.js"]