FROM node:18 AS build WORKDIR /app # Copy only package files first (better caching) COPY package*.json ./ # This layer will be cached if package.json doesn't change RUN npm ci --legacy-peer-deps # Copy source code (this changes more often) COPY . . RUN npm run build FROM nginx:alpine COPY --from=build /app/public /usr/share/nginx/html RUN echo 'server { listen 80; root /usr/share/nginx/html; index index.html; location / { try_files $uri $uri/ /index.html; } }' > /etc/nginx/conf.d/default.conf EXPOSE 80