I’m attempting to build my project in a docker container, but it’s failing. This build is part of a monorepo build, where the server, client and libs are all built in the same multi-stage Dockerfile.
Error:
> [builder 14/18] RUN npm run build --prefix ./app.client:
#25 0.452
#25 0.452 > app.client@1.0.0 build
#25 0.452 > webpack --env production=true --env extractCss=true
#25 0.452
#25 24.71 assets by status 4.31 MiB [cached] 51 assets
#25 24.71 Entrypoint app = 23 assets 45 auxiliary assets
#25 24.71 orphan modules 174 KiB [orphan] 44 modules
#25 24.71 runtime modules 5.39 KiB 12 modules
#25 24.71 javascript modules 4.27 MiB
#25 24.71 modules by path ./src/ 764 KiB 151 modules
#25 24.71 modules by path ./node_modules/ 3.51 MiB 88 modules
#25 24.71 modules by path ../client.models/ 15.6 KiB
#25 24.71 ../client.models/dist-es/index.js + 6 modules 9.2 KiB [built] [code generated]
#25 24.71 ../client.models/node_modules/dayjs/dayjs.min.js 6.42 KiB [built] [code generated]
#25 24.71 asset modules 924 bytes (javascript) 1.8 MiB (asset)
#25 24.71 modules by path ./src/ 840 bytes (javascript) 1.57 MiB (asset) 20 modules
#25 24.71 modules by path ./node_modules/ 84 bytes (javascript) 234 KiB (asset)
#25 24.71 ./node_modules/bootstrap-icons/font/fonts/bootstrap-icons.woff2?08efbba7c53d8c5413793eecb19b20bb 42 bytes (javascript) 100 KiB (asset) [built] [code generated]
#25 24.71 ./node_modules/bootstrap-icons/font/fonts/bootstrap-icons.woff?08efbba7c53d8c5413793eecb19b20bb 42 bytes (javascript) 134 KiB (asset) [built] [code generated]
#25 24.71 ./src/config/environment.json 41 bytes [built] [code generated]
#25 24.71
#25 24.71 ERROR in ./node_modules/aurelia-testing/dist/native-modules/aurelia-testing.js
#25 24.71 Module not found: Error: Can't resolve './compile-spy' in '/src/app.client/node_modules/aurelia-testing/dist/native-modules'
#25 24.71 resolve './compile-spy' in '/src/app.client/node_modules/aurelia-testing/dist/native-modules'
#25 24.71 using description file: /src/app.client/node_modules/aurelia-testing/package.json (relative path: ./dist/native-modules)
#25 24.71 Field 'browser' doesn't contain a valid alias configuration
#25 24.71 using description file: /src/app.client/node_modules/aurelia-testing/package.json (relative path: ./dist/native-modules/compile-spy)
#25 24.71 no extension
#25 24.71 Field 'browser' doesn't contain a valid alias configuration
#25 24.71 /src/app.client/node_modules/aurelia-testing/dist/native-modules/compile-spy doesn't exist
#25 24.71 .ts
#25 24.71 Field 'browser' doesn't contain a valid alias configuration
#25 24.71 /src/app.client/node_modules/aurelia-testing/dist/native-modules/compile-spy.ts doesn't exist
#25 24.71 .tsx
#25 24.71 Field 'browser' doesn't contain a valid alias configuration
#25 24.71 /src/app.client/node_modules/aurelia-testing/dist/native-modules/compile-spy.tsx doesn't exist
#25 24.71 .js
#25 24.71 Field 'browser' doesn't contain a valid alias configuration
#25 24.71 /src/app.client/node_modules/aurelia-testing/dist/native-modules/compile-spy.js doesn't exist
#25 24.71 .jsx
#25 24.71 Field 'browser' doesn't contain a valid alias configuration
#25 24.71 /src/app.client/node_modules/aurelia-testing/dist/native-modules/compile-spy.jsx doesn't exist
#25 24.71 as directory
#25 24.71 /src/app.client/node_modules/aurelia-testing/dist/native-modules/compile-spy doesn't exist
#25 24.71 @ ./src/main.ts
#25 24.71 @ ./node_modules/aurelia-webpack-plugin/runtime/empty-entry.js
#25 24.71
#25 24.71 ERROR in ./node_modules/aurelia-testing/dist/native-modules/aurelia-testing.js
#25 24.71 Module not found: Error: Can't resolve './view-spy' in '/src/app.client/node_modules/aurelia-testing/dist/native-modules'
#25 24.71 resolve './view-spy' in '/src/app.client/node_modules/aurelia-testing/dist/native-modules'
#25 24.71 using description file: /src/app.client/node_modules/aurelia-testing/package.json (relative path: ./dist/native-modules)
#25 24.71 Field 'browser' doesn't contain a valid alias configuration
#25 24.71 using description file: /src/app.client/node_modules/aurelia-testing/package.json (relative path: ./dist/native-modules/view-spy)
#25 24.71 no extension
#25 24.71 Field 'browser' doesn't contain a valid alias configuration
#25 24.71 /src/app.client/node_modules/aurelia-testing/dist/native-modules/view-spy doesn't exist
#25 24.71 .ts
#25 24.71 Field 'browser' doesn't contain a valid alias configuration
#25 24.71 /src/app.client/node_modules/aurelia-testing/dist/native-modules/view-spy.ts doesn't exist
#25 24.71 .tsx
#25 24.71 Field 'browser' doesn't contain a valid alias configuration
#25 24.71 /src/app.client/node_modules/aurelia-testing/dist/native-modules/view-spy.tsx doesn't exist
#25 24.71 .js
#25 24.71 Field 'browser' doesn't contain a valid alias configuration
#25 24.71 /src/app.client/node_modules/aurelia-testing/dist/native-modules/view-spy.js doesn't exist
#25 24.71 .jsx
#25 24.71 Field 'browser' doesn't contain a valid alias configuration
#25 24.71 /src/app.client/node_modules/aurelia-testing/dist/native-modules/view-spy.jsx doesn't exist
#25 24.71 as directory
#25 24.71 /src/app.client/node_modules/aurelia-testing/dist/native-modules/view-spy doesn't exist
#25 24.71 @ ./src/main.ts
#25 24.71 @ ./node_modules/aurelia-webpack-plugin/runtime/empty-entry.js
#25 24.71
#25 24.71 webpack 5.73.0 compiled with 2 errors in 23073 ms
------
executor failed running [/bin/sh -c npm run build --prefix ./app.client]: exit code: 1
Just for an idea, here is the Dockerfile
.
# syntax=docker/dockerfile:1
FROM node:18.3.0 AS builder
WORKDIR /src
COPY ./client.models/package.json ./client.models/
RUN ls -al && cd ./client.models && npm install
COPY ./client.models/ ./client.models/
RUN npm run build --prefix ./client.models
COPY ./mongoose.models/package.json ./mongoose.models/
RUN ls -al && cd ./mongoose.models && npm install
COPY ./mongoose.models/ ./mongoose.models/
RUN npm run build --prefix ./mongoose.models
COPY ./app.client/package.json ./app.client/
RUN ls -al && cd ./app.client && npm install
COPY ./app.client/ ./app.client/
RUN npm run build --prefix ./app.client
COPY ./app.server/package.json ./app.server/
RUN ls -al && cd ./app.server && npm install --verbose
COPY ./app.server/ ./app.server/
RUN npm run webpack-build --prefix ./app.server
COPY ./app.client/dist/* ./app.server/dist/public/
FROM node:18.3.0-alpine
EXPOSE 5000
WORKDIR /app
COPY --chown=1000:1000 --from=builder /src/app.server/dist/* ./
USER 1000
CMD ["node", "./index.bundle.js"]
Building outside of docker works just fine.