# ========================= # BUILD STAGE # ========================= FROM node:16.20.2 AS build WORKDIR /app # Avoid npm randomness ENV NPM_CONFIG_LEGACY_PEER_DEPS=true ENV NPM_CONFIG_AUDIT=false ENV NPM_CONFIG_FUND=false # Copy dependency files first (better caching) COPY package*.json ./ # Clean install (IMPORTANT: single install only) RUN npm cache clean --force RUN npm install --legacy-peer-deps --no-audit --no-fund # Copy full project COPY . . # Build Ionic Angular app RUN npx ionic build --configuration production # ========================= # PRODUCTION STAGE (NGINX) # ========================= FROM nginx:alpine # Nginx config (optional but recommended for SPA routing) COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf # Clean default nginx files RUN rm -rf /usr/share/nginx/html/* # Copy build output from previous stage COPY --from=build /app/www /usr/share/nginx/html # Expose port EXPOSE 80 # Start nginx CMD ["nginx", "-g", "daemon off;"]