Skip to content

Commit f261e71

Browse files
committed
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
1 parent db27688 commit f261e71

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ node_modules/
2424
npm-debug.log*
2525
yarn-debug.log*
2626
yarn-error.log*
27+
package-lock.json
28+
yarn.lock
2729

2830
# Build artifacts
2931
target/

Dockerfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Use Node.js 18 as base image, then add Java
1+
# Use Node.js 18 as base image, then add Java
22
FROM node:18-slim
33

44
# Set working directory
@@ -25,7 +25,13 @@ COPY examples/basicauthentication/ui.resources /app/ui.resources
2525

2626
# Build the Angular frontend first
2727
WORKDIR /app/ui.resources
28-
RUN yarn install && yarn build
28+
# Use npm instead of yarn for better Docker reliability
29+
# Add network timeout and retry configurations
30+
RUN npm config set fetch-retry-mintimeout 20000 && \
31+
npm config set fetch-retry-maxtimeout 120000 && \
32+
npm config set fetch-retries 5 && \
33+
npm install && \
34+
npm run build
2935

3036
# Go back to app directory and build the Java application
3137
WORKDIR /app

examples/basicauthentication/pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@
193193
</configuration>
194194
<executions>
195195
<execution>
196-
<id>exec-yarn-install</id>
196+
<id>exec-npm-install</id>
197197
<phase>generate-sources</phase>
198198
<configuration>
199-
<executable>yarn</executable>
199+
<executable>npm</executable>
200200
<arguments>
201201
<argument>install</argument>
202202
</arguments>
@@ -209,8 +209,9 @@
209209
<id>exec-ngcli-build</id>
210210
<phase>generate-sources</phase>
211211
<configuration>
212-
<executable>ng</executable>
212+
<executable>npx</executable>
213213
<arguments>
214+
<argument>ng</argument>
214215
<argument>build</argument>
215216
<argument>--base-href=#context-path#</argument>
216217
</arguments>

0 commit comments

Comments
 (0)