如何解决即使Package.json具有““ start”:“ set PORT = 3500 && react-scripts start”,带有React-Service的Docker-compose始终会选择PORT 3000
我正在使用docker-compose运行一些微服务:
Dockerfile:
FROM node:alpine
WORKDIR '/app'
COPY ./package.json ./
RUN npm install
COPY . .
CMD ["npm","run","start"]
docker-compose.yaml:
version: '3'
services:
lb:
image: dockercloud/haproxy
links:
- api-gateway
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 80:80
- 443:443
restart: on-failure
api-gateway:
build:
context: .
dockerfile: development.Dockerfile
image: microservices-workshop/api-gateway:dev
restart: on-failure
environment:
- VIRTUAL_HOST=api-gateway.app.com
ports:
- 3000:3000
volumes:
- ./api-gateway:/app/src
delivery-service:
build:
context: .
dockerfile: development.Dockerfile
image: microservices-workshop/delivery-service:dev
restart: on-failure
volumes:
- ./delivery-service:/app/src
order-service:
build:
context: .
dockerfile: development.Dockerfile
image: microservices-workshop/order-service:dev
restart: on-failure
volumes:
- ./order-service:/app/src
restaurants-service:
build:
context: .
dockerfile: development.Dockerfile
image: microservices-workshop/restaurants-service:dev
restart: on-failure
volumes:
- ./restaurants-service:/app/src
react-service:
build:
context: ./react-service
dockerfile: Dockerfile
volumes:
- /node_modules
- ./react-service:/src
tty: true
ports:
- 3500:3500
这是React应用的Package.JSON:
{
"name": "reactservice","version": "0.1.0","private": true,"dependencies": {
"@testing-library/jest-dom": "^4.2.4","@testing-library/react": "^9.5.0","@testing-library/user-event": "^7.2.1","react": "^16.13.1","react-dom": "^16.13.1","react-scripts": "3.4.2"
},"scripts": {
"start": "set PORT=3500 && react-scripts start","build": "react-scripts build","test": "react-scripts test","eject": "react-scripts eject"
},"eslintConfig": {
"extends": "react-app"
},"browserslist": {
"production": [
">0.2%","not dead","not op_mini all"
],"development": [
"last 1 chrome version","last 1 firefox version","last 1 safari version"
]
}
}
但是当我按下docker-compose up
时,我得到了:
Compiled successfully!
react-service_1 |
react-service_1 | You can now view reactservice in the browser.
react-service_1 |
react-service_1 | Local: http://localhost:3000
react-service_1 | On Your Network: http://172.20.0.4:3000
react-service_1 |
react-service_1 | Note that the development build is not optimized.
react-service_1 | To create a production build,use npm run build.
react-service_1 |
...即使我已将端口设置为3500
。
我哪里出错了?
顺便说一句,我在WINDOWS 10下工作
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。