# Build stage FROM node:20-slim as build # Set working directory WORKDIR /app # Install dependencies first to leverage Docker cache COPY package.json yarn.lock* ./ # Install dependencies RUN yarn install --frozen-lockfile --network-timeout 1000000 # Copy the rest of the application COPY . . # Build the application RUN yarn build # Production stage FROM nginx:alpine # Copy built assets from build stage COPY --from=build /app/dist /usr/share/nginx/html # Copy custom nginx config COPY docker/nginx.conf /etc/nginx/conf.d/default.conf # Copy static assets and error page COPY public/ /usr/share/nginx/html/ # Set proper permissions RUN chmod -R 755 /usr/share/nginx/html && \ chown -R nginx:nginx /usr/share/nginx/html # Expose the port the app runs on EXPOSE 80 # Start Nginx CMD ["nginx", "-g", "daemon off;"]