# syntax=docker/dockerfile:1.7 # --- Build stage ------------------------------------------------------------ FROM node:20-alpine AS build WORKDIR /app # Copy package files for dependency caching COPY package*.json ./ RUN npm ci # Copy source and build COPY . . RUN npm run build # Verify build output RUN ls -la dist/ && test -f dist/index.html || (echo "ERROR: index.html not found!" && exit 1) # --- Runtime stage ---------------------------------------------------------- FROM nginx:1.27-alpine AS runtime # Install wget for healthcheck RUN apk add --no-cache wget # Copy nginx config COPY nginx.conf /etc/nginx/conf.d/default.conf # Copy built app COPY --from=build /app/dist/ /usr/share/nginx/html/ # Verify files were copied RUN ls -la /usr/share/nginx/html/ && test -f /usr/share/nginx/html/index.html || (echo "ERROR: index.html not copied!" && exit 1) EXPOSE 80 # Healthcheck HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=10s \ CMD wget --no-verbose --tries=1 --spider http://127.0.0.1/ || exit 1