umi docker中部署问题

Created on 6 Jun 2018  ·  16Comments  ·  Source: umijs/umi

用dva+umi的CRUD项目,docker镜像打包后一直会卡在umi dev无法继续走下去,Dockerfile

FROM node
WORKDIR /app
COPY ./package.json /app
RUN npm install
COPY ./ /app
CMD ["npm", "start"]
type(question)

Most helpful comment

你本地的node镜像是不是太老了?

➜  ~ docker run --rm node npm -v
6.1.0

All 16 comments

没用过 docker 。。

能把Dockerfile贴上来看一下吗?

我用umii-antd-admin这个项目加上你提供的Dockerfile试了一下,是没有问题的

@hansnow
umijs/umi-dva-user-dashboard
这个项目就有问题,因为自己项目也是按着dashboard的项目开始的

我试了你提到的umi-dva-user-dashboard项目,依然没有问题

我是直接镜像打包以后,放入的docker,用npm start起的,不是用build打包后的dist部署的

把Dockerfile放到项目根目录之后

docker build -t hansnow/umi-demo .
docker run -p 8000:8000 hansnow/umi-demo

然后访问yourip:8000就可以了。你是怎么操作的呢?

你是在启动容器的时候卡死的吧?试试把项目项目从/app改成/web/app看看

`$ docker build -t umi-dva .
Sending build context to Docker daemon 290.9MB
Step 1/6 : FROM node
---> d17c9e1d584e
Step 2/6 : WORKDIR /app
Removing intermediate container 908bc490f6a0
---> a0b469f167ec
Step 3/6 : COPY ./package.json /app
---> e84339de2127
Step 4/6 : RUN npm install
---> Running in b78f3808e54f
npm WARN deprecated [email protected]: 1.2.0 should have been a major version bump
npm WARN deprecated [email protected]: Package no longer supported. Contact [email protected] for more info.

[email protected] install /app/node_modules/husky
node ./bin/install.js

husky
setting up hooks
Can't find .git directory, skipping Git hooks installation

[email protected] postinstall /app/node_modules/preact
node -e "console.log('\u001b[35m\u001b[1mLove Preact? You can now donate to our open collective:\u001b[22m\u001b[39m\n > \u001b[34mhttps://opencollective.com/preact/donate\u001b[0m')"

Love Preact? You can now donate to our open collective:

https://opencollective.com/preact/donate

[email protected] postinstall /app/node_modules/uglifyjs-webpack-plugin
node lib/post_install.js

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN @babel/[email protected] requires a peer of @babel/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @babel/[email protected] requires a peer of @babel/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN @babel/[email protected] requires a peer of @babel/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of babel-eslint@^7.2.3 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-native@* but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-native@* but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of jest@^22.0.1 || ^22.1.0-alpha.1 || ^23.0.0-alpha.1 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 1964 packages from 1104 contributors and audited 46471 packages in 52.06s
found 4 moderate severity vulnerabilities
run npm audit fix to fix them, or npm audit for details
Removing intermediate container b78f3808e54f
---> bc36551a0228
Step 5/6 : COPY ./ /app
---> 0afa592a5185
Step 6/6 : CMD ["npm", "start"]
---> Running in 01c249310018
Removing intermediate container 01c249310018
---> 41e5ae9d225e
Successfully built 41e5ae9d225e
Successfully tagged umi-dva:latest
$ docker run -p 8000:8000 umi-dva

@ start /app
umi dev`

然后最后就输出下面两行,访问8000无效。最终只能打成dist后用docker nginx部署
@ start /app
umi dev

神奇的问题...我在Mac和Linux试了一下,都没有问题。你上面贴的日志确定是umi-dva-user-dashboard这个项目的吧?

@hansnow 是的 直接拉下来的。然后用docker跑的,难道是docker的问题

我已找到问题所在,我用的是npm 5.6.0版本,会有问题,升级npm 6.0版本,umii-antd-admin没问题

你本地的node镜像是不是太老了?

➜  ~ docker run --rm node npm -v
6.1.0

@hansnow 应该就是这个问题

看来有结论了,我 close 了。

Was this page helpful?
0 / 5 - 0 ratings