From f261e7142f51fdb789aa1b6a31faba963eb9f10f Mon Sep 17 00:00:00 2001 From: Suren K Date: Wed, 1 Oct 2025 16:22:15 -0500 Subject: [PATCH] fix: Improve network reliability for Docker builds - Switch from yarn to npm for better Docker reliability - Add npm network timeout and retry configurations - Set fetch-retry-mintimeout: 20000ms - Set fetch-retry-maxtimeout: 120000ms - Set fetch-retries: 5 attempts - Update Maven exec plugin to use npm instead of yarn - Use npx for Angular CLI execution - Add package-lock.json and yarn.lock to .dockerignore - Resolves ESOCKETTIMEDOUT network issues during build --- .dockerignore | 2 ++ Dockerfile | 10 ++++++++-- examples/basicauthentication/pom.xml | 7 ++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index c5f2cc95..b0c745e9 100644 --- a/.dockerignore +++ b/.dockerignore @@ -24,6 +24,8 @@ node_modules/ npm-debug.log* yarn-debug.log* yarn-error.log* +package-lock.json +yarn.lock # Build artifacts target/ diff --git a/Dockerfile b/Dockerfile index 0ccc58a0..274743fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -# Use Node.js 18 as base image, then add Java + # Use Node.js 18 as base image, then add Java FROM node:18-slim # Set working directory @@ -25,7 +25,13 @@ COPY examples/basicauthentication/ui.resources /app/ui.resources # Build the Angular frontend first WORKDIR /app/ui.resources -RUN yarn install && yarn build +# Use npm instead of yarn for better Docker reliability +# Add network timeout and retry configurations +RUN npm config set fetch-retry-mintimeout 20000 && \ + npm config set fetch-retry-maxtimeout 120000 && \ + npm config set fetch-retries 5 && \ + npm install && \ + npm run build # Go back to app directory and build the Java application WORKDIR /app diff --git a/examples/basicauthentication/pom.xml b/examples/basicauthentication/pom.xml index e1dd5262..5ddaa0aa 100644 --- a/examples/basicauthentication/pom.xml +++ b/examples/basicauthentication/pom.xml @@ -193,10 +193,10 @@ - exec-yarn-install + exec-npm-install generate-sources - yarn + npm install @@ -209,8 +209,9 @@ exec-ngcli-build generate-sources - ng + npx + ng build --base-href=#context-path#