我正在 AWS ECS 上使用 docker 部署 create-react-app。我正在使用 dockerhub 图像进行测试,这几乎是 create-react-app 的库存版本。启动任务时,它能够拉取容器映像,启动 docker 容器,但是它挂在运行 react-scripts start 上。我可以在容器日志中看到的是:
01:51:38 npm info it worked if it ends with ok
01:51:38 npm info using npm@2.15.11
01:51:38 npm info using node@v4.7.3
01:51:42 npm info prestart test-react@0.1.0
01:51:42 npm info start test-react@0.1.0
01:51:42 > test-react@0.1.0 start /usr/src/app
01:51:42 > react-scripts start
01:52:06 Starting the development server...
它只是挂在那里,永远不会结束。但是,当我手动运行 docker 容器时,一切正常:
Starting the development server...
Compiled successfully!
The app is running at:
http://localhost:3000/
我的 Dockerfile 是:
FROM node:4-onbuild
# Prepare app directory
RUN mkdir -p /usr/src/app
ADD . /usr/src/app
# Install dependencies
WORKDIR /usr/src/app
RUN npm install
# Build the app
RUN npm build
# Expose the app port
EXPOSE 3000
# Start the app
CMD npm start --loglevel debug
我的 package.json:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
寻找有关如何调试的建议,或者我可以做额外的日志记录,谢谢!