Skip to content

Commit c59b47c

Browse files
authored
Merge pull request #252 from FoxxMD/paralellBuild
feat(docker): Paralellize npm install and build processes
2 parents e2775cd + 0e4845f commit c59b47c

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ RUN \
4949

5050
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
5151

52+
RUN npm install -g concurrently
53+
5254
ARG data_dir=/config
5355
VOLUME $data_dir
5456
ENV CONFIG_DIR=$data_dir
@@ -61,6 +63,7 @@ FROM base AS build
6163

6264
COPY --chown=abc:abc package*.json tsconfig.json ./
6365
COPY --chown=abc:abc patches ./patches
66+
COPY --chown=abc:abc docsite/package*.json tsconfig.json ./docsite/
6467

6568
# for debugging, so the build fails faster when timing out (arm64)
6669
#RUN npm config set fetch-retries 1 && \
@@ -74,16 +77,16 @@ COPY --chown=abc:abc patches ./patches
7477

7578
# This FAILED for node < 20 when building arm64 but not amd64 (and alpine-based Dockerfile has no issues building arm64)
7679
# see https://github.com/FoxxMD/multi-scrobbler/issues/126
77-
RUN npm ci \
78-
--no-audit \
79-
&& chown -R root:root node_modules
80+
RUN npm run install:parallel \
81+
&& chown -R root:root node_modules \
82+
&& chown -R root:root docsite/node_modules
8083

8184
COPY --chown=abc:abc . /app
8285

8386
# need to set before build so server/client build is optimized and has constants (if needed)
8487
ENV NODE_ENV=production
8588

86-
RUN npm run docs:install && npm run schema && npm run build && rm -rf node_modules && rm -rf docsite/node_modules
89+
RUN npm run build:parallel && rm -rf node_modules && rm -rf docsite/node_modules
8790

8891
FROM base AS app
8992

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
"build:frontend": "vite build",
1414
"build:backend": "tsc -p src/backend",
1515
"build": "npm run -s build:backend && npm run -s build:frontend && npm run -s docs:build",
16-
"docs:install": "cd docsite && npm ci",
16+
"build:parallel": "concurrently --kill-others-on-fail --names backend,frontend,docs \"npm run -s build:backend\" \"npm run -s build:frontend\" \"npm run docs:build\"",
17+
"docs:install": "cd docsite && npm ci --no-audit",
1718
"docs:start": "cd docsite && npm start",
18-
"docs:build": "cd docsite && npm run build",
19-
"postinstall": "patch-package"
19+
"docs:build": "npm run schema && cd docsite && npm run build",
20+
"postinstall": "patch-package",
21+
"install:parallel": "concurrently --kill-others-on-fail --names app,docs \"npm ci --no-audit\" \"npm run docs:install\""
2022
},
2123
"exports": {
2224
".": {

0 commit comments

Comments
 (0)