【发布时间】:2019-07-20 00:47:20
【问题描述】:
我有一个使用 reactjs 的示例项目,下面的 nodejs 是文件夹结构。
movielisting
Dockerfile
client
package.json
package.lock.json
... other create-react-app folders like src..
server
index.js
我通过 npm run start - 客户端文件夹和 nodemon index.js - 服务器文件夹启动这个项目。我所有的api都写在服务器文件夹中。我的客户端在 3000 端口运行,服务器在 4000 端口运行,我在客户端的 package.json 中添加了代理,如下所示
"proxy": "http://localhost:4000"
所以我想在 Dockerfile 中实现的是我想通过运行这个 Dockerfile 来启动应用程序
1) i need to create the build of client by running npm run build
2) copy to the workdir inside the container
3) copy all server folder
4) npm install for the server folder
5) proxy the application
我该怎么做呢?我是否需要在 nodejs 中编写一些代码来为构建 index.html 文件提供服务
还有如何运行 Dockerfile 命令来运行应用程序。
任何帮助表示赞赏!!!
【问题讨论】: