# Build stage FROM node:lts-alpine AS build WORKDIR /app # Install dependencies first to leverage Docker cache COPY package*.json ./ RUN npm ci --no-audit --no-fund --omit=dev && \ npm cache clean --force # Copy source code and build COPY . . RUN npm run build # Runtime stage FROM httpd:2.4-alpine AS runtime # Copy custom httpd config if needed # COPY ./httpd.conf /usr/local/apache2/conf/httpd.conf # Copy built assets from build stage COPY --from=build /app/dist /usr/local/apache2/htdocs/ # Add security headers RUN echo 'Header set X-Content-Type-Options "nosniff"' >> /usr/local/apache2/conf/httpd.conf && \ echo 'Header set X-Frame-Options "SAMEORIGIN"' >> /usr/local/apache2/conf/httpd.conf && \ echo 'Header set X-XSS-Protection "1; mode=block"' >> /usr/local/apache2/conf/httpd.conf EXPOSE 80 # Health check HEALTHCHECK --interval=30s --timeout=3s \ CMD wget --quiet --tries=1 --spider http://localhost:80/ || exit 1