Vite + Esbuild Docker issue
See original GitHub issueDescribe the bug
I’m trying to Docker build my app, and although the build phase is working fine on my laptop, I’m getting this when building the Docker image:
> [build-stage 6/6] RUN npm run build:
#10 0.436
#10 0.436 > tailwind-dashboard@0.0.1 build /app
#10 0.436 > cross-env NODE_ENV=production vite build --debug
#10 0.436
#10 0.766 [vite] failed to load config from /app/vite.config.js:
#10 0.771 Error: spawn Unknown system error -8
#10 0.771 at ChildProcess.spawn (internal/child_process.js:403:11)
#10 0.771 at Object.spawn (child_process.js:553:9)
#10 0.771 at Object.startService (/app/node_modules/esbuild/lib/main.js:1066:29)
#10 0.771 at ensureService (/app/node_modules/vite/dist/node/esbuildService.js:39:37)
#10 0.771 at Object.transform (/app/node_modules/vite/dist/node/esbuildService.js:53:27)
#10 0.771 at Object.renderChunk (/app/node_modules/vite/dist/node/build/buildPluginEsbuild.js:39:37)
#10 0.771 at /app/node_modules/rollup/dist/shared/rollup.js:18804:25 {
#10 0.771 errno: -8,
#10 0.771 code: 'PLUGIN_ERROR',
#10 0.771 syscall: 'spawn',
#10 0.771 pluginCode: 'Unknown system error -8',
#10 0.771 plugin: 'vite:esbuild-transpile',
#10 0.771 hook: 'renderChunk'
#10 0.771 }
My Dockerfile is the same as in the Vue documentation:
# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
# production stage
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Reproduction
Use the Dockerfile above to run the app located at https://github.com/ocervell/v-dashboard/tree/slo-ui-v1.
System Info
Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers
:
System:
OS: macOS 10.15.7
CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Memory: 9.70 GB / 32.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 15.10.0 - ~/homebrew/bin/node
Yarn: 1.22.10 - ~/Workspace/dev/poc/slo-generator-poc/slo-generator-ui/node_modules/.bin/yarn
npm: 7.5.3 - ~/homebrew/bin/npm
Browsers:
Chrome: 89.0.4389.90
Safari: 14.0.3
npmPackages:
vite: ^1.0.0-rc.8 => 1.0.0-rc.13
Logs
[build-stage 6/6] RUN npm run build: #12 0.455 #12 0.455 > tailwind-dashboard@0.0.1 build /app #12 0.455 > cross-env NODE_ENV=production vite build --debug #12 0.455 #12 0.803 [vite] failed to load config from /app/vite.config.js: #12 0.820 Error: spawn Unknown system error -8 #12 0.820 at ChildProcess.spawn (internal/child_process.js:403:11) #12 0.820 at Object.spawn (child_process.js:553:9) #12 0.820 at Object.startService (/app/node_modules/esbuild/lib/main.js:1066:29) #12 0.820 at ensureService (/app/node_modules/vite/src/node/esbuildService.ts:52:23) #12 0.820 at Object.transform (/app/node_modules/vite/src/node/esbuildService.ts:72:25) #12 0.820 at Object.renderChunk (/app/node_modules/vite/src/node/build/buildPluginEsbuild.ts:56:14) #12 0.820 at /app/node_modules/rollup/dist/shared/rollup.js:18804:25 { #12 0.820 errno: -8, #12 0.820 code: ‘PLUGIN_ERROR’, #12 0.820 syscall: ‘spawn’, #12 0.820 pluginCode: ‘Unknown system error -8’, #12 0.820 plugin: ‘vite:esbuild-transpile’, #12 0.820 hook: ‘renderChunk’ #12 0.820 } #12 0.836 npm ERR! code ELIFECYCLE #12 0.837 npm ERR! errno 1 #12 0.841 npm ERR! tailwind-dashboard@0.0.1 build:
cross-env NODE_ENV=production vite build --debug
#12 0.841 npm ERR! Exit status 1 #12 0.841 npm ERR! #12 0.842 npm ERR! Failed at the tailwind-dashboard@0.0.1 build script. #12 0.842 npm ERR! This is probably not a problem with npm. There is likely additional logging output above. #12 0.847 #12 0.847 npm ERR! A complete log of this run can be found in: #12 0.847 npm ERR! /root/.npm/_logs/2021-03-24T10_58_32_077Z-debug.log
failed to solve with frontend dockerfile.v0: failed to build LLB: executor failed running [/bin/sh -c npm run build]: runc did not terminate sucessfully.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top GitHub Comments
or
Copying this over here in case anyone’s looking for another workaround. Add an ENTRYPOINT, and the correct architecture will be built inside the container on startup. This way you don’t need to exclude your
node_modules
using an empty volume either.entrypoint.sh
Dockerfile
(Alternatively, simply run
npm rebuild esbuild
withdocker exec
ordocker compose exec
)