FROM node:18-alpine AS base WORKDIR /app # 1) Install dependencies (cached until package files change) COPY package*.json ./ RUN npm ci # 2) Build the React client (only re-run when client sources change) COPY public ./public COPY src ./src RUN npm run build # 3) Copy server-side files (changes here skip the expensive client build layer) COPY server.js ./ COPY services ./services RUN mkdir -p config ENV NODE_ENV=production EXPOSE 3000 CMD ["node", "server.js"]