# Build stage FROM quay.io/fedora/nodejs-18:latest as build # Create directory with proper ownership RUN mkdir -p /opt/app-root/src && \ chown 1001:1001 /opt/app-root/src # Switch to the directory where we have permission to write WORKDIR /opt/app-root/src # Copy package.json with correct ownership COPY --chown=1001:1001 package*.json ./ # Install dependencies with minimum options to reduce failures ENV NODE_OPTIONS="--max-old-space-size=4096" ENV NODE_ENV=production # Install all dependencies (including dev dependencies needed for build) RUN npm config set registry https://registry.npmjs.org/ && \ npm install --no-optional --loglevel=error # Copy the rest of the application COPY --chown=1001:1001 . ./ # Build the application RUN npm run build # Production stage - using the UBI nginx image for minimal footprint FROM quay.io/fedora/ubi8/nginx-126 # Copy build output directly to NGINX html directory COPY --from=build /opt/app-root/src/build/ /usr/share/nginx/html/ # Copy NGINX configuration COPY nginx.conf "${NGINX_CONF_PATH}" # Set correct permissions for NGINX RUN chmod -R 0777 /usr/share/nginx/html/ # Run the application CMD nginx -g "daemon off;"