【发布时间】:2020-11-17 04:16:27
【问题描述】:
我有一个反应构建和一个服务器构建 (mongo) 例如
- root
- server
-build
DockerFile
-client
-build
DockerFile
docker-compose.yml
这在推送时使用 github 操作来构建和部署到 AWS 实例
服务器在单独端口上的 prod 上运行良好,但是我缺少能够在此主机上运行客户端的东西。如果可以的话,我不想通过我的 express api 提供我所有的静态资产。
Docker 编写文件:
version: '3'
services:
client:
build:
context: ./client
dockerfile: Dockerfile
volumes:
- /app/node_modules
- ./client:/usr/src/app
ports:
- '3000:3000'
restart: on-failure
container_name: spacer_app_client
tty: true
stdin_open: true
server:
build:
context: ./server
dockerfile: Dockerfile
ports:
- '3001:3001'
restart: on-failure
container_name: spacer_app_server
stdin_open: true
volumes:
- /app/node_modules # Inside the container, don't try to override this folder, just leave as is
- ./server:/usr/src/app # Look at the server directory and copy everything into the app folder in the container
【问题讨论】:
-
很抱歉,但我们并没有真正得到您想要实现的目标。 “在这台主机上运行我的客户端”是什么意思?另外我不明白静态资产问题的重点?如果您需要第三个带有 Web 服务器 nginx/apache 的容器,只需将其添加到您的撰写文件中。
-
对不起,我没有很好地解释 myseld。我想就是这样,我的 docker 文件中需要一个 nginx 服务器才能托管静态文件,但不确定命令/如何做到这一点
-
你能展示你的 docker-compose.yml 吗?这是您使用提供一些静态文件的 nginx 容器放置第三个容器的地方...
-
当然!感谢您的输入。我会将它添加到主要问题的编辑中
标签: reactjs docker amazon-ec2 github-actions