go-admin-team / go-admin-ui

基于Gin + Vue + Element UI & Arco Design & Ant Design 的前后端分离权限管理系统的前端模块
https://www.go-admin.dev
MIT License
1.17k stars 719 forks source link

docker build error #204

Open jiftle opened 2 years ago

jiftle commented 2 years ago

os: [Release] Version=20.7.1 Type=Desktop Type[zh_CN]=社区版 Edition=Y2020E0001 Copyright=Y2020CR001 [Addition] Milestone= Buildid=build1

error

 docker build ./ -t t
Sending build context to Docker daemon  466.3MB
Step 1/11 : FROM registry.cn-shanghai.aliyuncs.com/lwmeng/node:lts-alpine as build-stage
lts-alpine: Pulling from lwmeng/node
0a6724ff3fcd: Pull complete 
9383f33fa9f3: Pull complete 
b6ae88d676fe: Pull complete 
565e01e00588: Pull complete 
Digest: sha256:bef791f512bb4c3051a1210d7fbd58206538f41eea9b966031abc8a7453308fe
Status: Downloaded newer image for registry.cn-shanghai.aliyuncs.com/lwmeng/node:lts-alpine
 ---> 51d926a5599d
Step 2/11 : WORKDIR /app
 ---> Running in ae7236339dd9
Removing intermediate container ae7236339dd9
 ---> 8f26a77c0e1b
Step 3/11 : COPY package*.json ./
 ---> 70846eea7e50
Step 4/11 : RUN npm install -g cnpm --registry=https://registry.npmmirror.com
 ---> Running in 36ba2a281ae1
/usr/local/bin/cnpm -> /usr/local/lib/node_modules/cnpm/bin/cnpm
npm WARN notsup Unsupported engine for urllib@3.5.0: wanted: {"node":">= 14.17.0"} (current: {"node":"14.15.3","npm":"6.14.9"})
npm WARN notsup Not compatible with your version of node/npm: urllib@3.5.0                                                                                                

+ cnpm@8.4.0                                                                                                                                                              
added 572 packages from 205 contributors in 27.979s
Removing intermediate container 36ba2a281ae1
 ---> 5751c2a0bee7
Step 5/11 : RUN cnpm install
 ---> Running in 4648c7177199
internal/modules/cjs/loader.js:883
  throw err;                                                                                                                                                              
  ^                                                                                                                                                                       

Error: Cannot find module 'diagnostics_channel'                                                                                                                           
Require stack:                                                                                                                                                            
- /usr/local/lib/node_modules/cnpm/node_modules/urllib/src/cjs/diagnosticsChannel.js                                                                                      
- /usr/local/lib/node_modules/cnpm/node_modules/urllib/src/cjs/HttpClient.js                                                                                              
- /usr/local/lib/node_modules/cnpm/node_modules/urllib/src/cjs/index.js                                                                                                   
- /usr/local/lib/node_modules/cnpm/node_modules/npminstall/lib/get.js                                                                                                     
- /usr/local/lib/node_modules/cnpm/node_modules/npminstall/lib/utils.js                                                                                                   
- /usr/local/lib/node_modules/cnpm/node_modules/npminstall/lib/local_install.js                                                                                           
- /usr/local/lib/node_modules/cnpm/node_modules/npminstall/lib/index.js                                                                                                   
- /usr/local/lib/node_modules/cnpm/node_modules/npminstall/bin/install.js                                                                                                 
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)                                                                                           
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)                                                                                                      
    at Module.require (internal/modules/cjs/loader.js:952:19)                                                                                                             
    at require (internal/modules/cjs/helpers.js:88:18)                                                                                                                    
    at Object.<anonymous> (/usr/local/lib/node_modules/cnpm/node_modules/urllib/src/cjs/diagnosticsChannel.js:5:55)                                                       
    at Module._compile (internal/modules/cjs/loader.js:1063:30)                                                                                                           
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)                                                                                             
    at Module.load (internal/modules/cjs/loader.js:928:32)                                                                                                                
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)                                                                                                      
    at Module.require (internal/modules/cjs/loader.js:952:19) {                                                                                                           
  code: 'MODULE_NOT_FOUND',                                                                                                                                               
  requireStack: [                                                                                                                                                         
    '/usr/local/lib/node_modules/cnpm/node_modules/urllib/src/cjs/diagnosticsChannel.js',                                                                                 
    '/usr/local/lib/node_modules/cnpm/node_modules/urllib/src/cjs/HttpClient.js',                                                                                         
    '/usr/local/lib/node_modules/cnpm/node_modules/urllib/src/cjs/index.js',                                                                                              
    '/usr/local/lib/node_modules/cnpm/node_modules/npminstall/lib/get.js',                                                                                                
    '/usr/local/lib/node_modules/cnpm/node_modules/npminstall/lib/utils.js',                                                                                              
    '/usr/local/lib/node_modules/cnpm/node_modules/npminstall/lib/local_install.js',                                                                                      
    '/usr/local/lib/node_modules/cnpm/node_modules/npminstall/lib/index.js',                                                                                              
    '/usr/local/lib/node_modules/cnpm/node_modules/npminstall/bin/install.js'                                                                                             
  ]                                                                                                                                                                       
}                                                                                                                                                                         
The command '/bin/sh -c cnpm install' returned a non-zero code: 1 
wanghao-bianjie commented 2 years ago

修改 dockerfile 文件:

FROM registry.cn-shanghai.aliyuncs.com/lwmeng/node:lts-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build:prod

FROM registry.cn-shanghai.aliyuncs.com/lwmeng/nginx
COPY --from=build-stage /app/dist /usr/share/nginx/html

EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]