Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加Docker支持 #37

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
Open

增加Docker支持 #37

wants to merge 10 commits into from

Conversation

Qquanwei
Copy link

@Qquanwei Qquanwei commented Feb 7, 2018

目前项目内的配置缺少有关docker的,所以需要修改部分配置才可以运行。

跑docker前需要修改 client/config/index.js, 将ip替换成跑docker宿主vm地址

 build.serverRoot: '192.168.99.100/mock-api'

编译docker镜像

> cd client
> npm install
> cd ..
> npm run docker:build

运行docker容器

> npm run docker:start
# client 8888 server 7001
# open 192.168.99.100:8888

然后打开docker vm ip:8888即可
win/mac 下一般默认的docker vm ip为 192.168.99.100.

目前的不足.

  • mongod 现在默认连接地址为 127.0.0.1 , 导致docker只能通过共享network namespace来连接两个容器,这样不利于容器的独立 也不利于分布式数据库的部署。 建议server端连接 mongodb://api-mongo:27017
    给mongo分配一个独立的域名连接,因为mongo总是运行在内网环境,所以只需部署机增加host映射即可。好处是可以动态更换ip,方便docker部署。

  • client/config/index.js 这里的动态ip可能无法适应目前的环境,如果能静态编译时生成ip最好了。

@Qquanwei
Copy link
Author

Qquanwei commented Feb 7, 2018

此外,在docker中跑api-mocker,功能都正常,但是样式没了。也没看到网络报错,很神奇。
image

@Qquanwei
Copy link
Author

Anyone follow this PR ?

@wuomzfx
Copy link
Contributor

wuomzfx commented Nov 13, 2018

nobody

@Qquanwei
Copy link
Author

Procrastination. 🤓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants