# Stage 1: Build FROM node:20-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm install --legacy-peer-deps COPY . . RUN npm run build # Stage 2: Runtime (NGINX) FROM nginx:alpine # Install dos2unix to fix Windows line endings RUN apk add --no-cache dos2unix # Clean default nginx html RUN rm -rf /usr/share/nginx/html/* # Copy built frontend COPY --from=builder /app/dist /usr/share/nginx/html # Copy entrypoint and normalize line endings COPY docker-entrypoint.sh /docker-entrypoint.sh RUN dos2unix /docker-entrypoint.sh && chmod +x /docker-entrypoint.sh # Fallback env.js (to avoid 404 before initContainer writes real one) RUN echo "window.env = {}" > /usr/share/nginx/html/env.js # Set entrypoint ENTRYPOINT ["/docker-entrypoint.sh"]