Docker + Django + Angular + Heroku + Postgresql – 进程退出状态127,错误代码= H10 desc =“应用程序崩溃”

我想部署在Heroku我的项目在Docker与Angular 4前端,Django后端和postgresql数据库。 在这个时候我的文件看起来如下所示。 我记得确定这是否正确完成? 我使用heroku container:push web --app myproject推送它heroku container:push web --app myproject但它不起作用(日志)。 当我运行docker-compose up没有Heroku一切似乎正常工作。

我注意到在日志中有Process exited with status 127 。 我在这里find127返回码$? 那

Value 127 is returned by /bin/sh when the given command is not found within your PATH system variable and it is not a built-in shell command. In other words, the system doesn't understand your command, because it doesn't know where to find the binary you're trying to call.

另外,当我尝试不同的命令时,我经常会遇到像/bin/sh: 1 not found这样的错误/bin/sh: 1 not found我在这篇文章中描述的内容。 也许这是问题的根源? 或者最终在这种情况下端口有问题?

任何其他的想法? 在我看来,我正在尝试一切。 我不知道什么是错的。

如果你能告诉我,我是否正在做一切事情,我将不胜感激。

 1.`heroku login` 2.`heroku container:login` 3.`heroku create nameofmyapp` 4.`heroku container:push web --app nameofmyapp` 5.`heroku open --app nameofmyapp` 

日志:

 2017-07-08T13:19:48.882112+00:00 heroku[web.1]: Process exited with status 0 2017-07-08T13:20:40.336825+00:00 heroku[run.9745]: Awaiting client 2017-07-08T13:20:40.395900+00:00 heroku[run.9745]: Starting process with command `docker-compose up` 2017-07-08T13:20:40.542168+00:00 heroku[run.9745]: State changed from starting to up 2017-07-08T13:20:45.727667+00:00 heroku[run.9745]: State changed from up to complete 2017-07-08T13:20:45.715556+00:00 heroku[run.9745]: Process exited with status 127 2017-07-08T13:21:39.171330+00:00 heroku[run.8300]: Awaiting client 2017-07-08T13:21:39.198870+00:00 heroku[run.8300]: Starting process with command `docker-compose up` 2017-07-08T13:21:39.470489+00:00 heroku[run.8300]: State changed from starting to up 2017-07-08T13:21:43.381827+00:00 heroku[run.8300]: State changed from up to complete 2017-07-08T13:21:43.369201+00:00 heroku[run.8300]: Process exited with status 127 2017-07-08T13:25:26.780464+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=myapp.herokuapp.com request_id=cb876e32-ca19-467e-85a6-5babab50beab fwd="109.153.174.199" dyno= connect= service= status=503 bytes= protocol=https Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect... 2017-07-08T13:20:40.336825+00:00 heroku[run.9745]: Awaiting client 2017-07-08T13:20:40.395900+00:00 heroku[run.9745]: Starting process with command `docker-compose up` 2017-07-08T13:20:40.542168+00:00 heroku[run.9745]: State changed from starting to up 2017-07-08T13:20:45.727667+00:00 heroku[run.9745]: State changed from up to complete 2017-07-08T13:20:45.715556+00:00 heroku[run.9745]: Process exited with status 127 2017-07-08T13:21:39.171330+00:00 heroku[run.8300]: Awaiting client 2017-07-08T13:21:39.198870+00:00 heroku[run.8300]: Starting process with command `docker-compose up` 2017-07-08T13:21:39.470489+00:00 heroku[run.8300]: State changed from starting to up 2017-07-08T13:21:43.381827+00:00 heroku[run.8300]: State changed from up to complete 2017-07-08T13:21:43.369201+00:00 heroku[run.8300]: Process exited with status 127 2017-07-08T13:25:26.780464+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=myapp.herokuapp.com request_id=cb876e32-ca19-467e-85a6-5babab50beab fwd="109.153.174.199" dyno= connect= service= status=503 bytes= protocol=https 

项目树:

 ├── Backend │ ├── AI │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-36.pyc │ │ │ ├── settings.cpython-36.pyc │ │ │ ├── urls.cpython-36.pyc │ │ │ └── wsgi.cpython-36.pyc │ │ ├── settings.py │ │ ├── urls.py │ │ └── wsgi.py │ └── manage.py ├── Dockerfile ├── init.sql ├── Frontend │ └── angularProject ├── Dockerfile │ └── all files in my angular project ├── docker-compose.yml └── requirements.txt 

前端的Dockerfile:

 # Create image based on the official Node 6 image from dockerhub FROM node:6 # Create a directory where our app will be placed RUN mkdir -p /usr/src/app # Change directory so that our commands run inside this new directory WORKDIR /usr/src/app # Copy dependency definitions COPY package.json /usr/src/app # Install dependecies RUN npm install # Get all the code needed to run the app COPY . /usr/src/app # Expose the port the app runs in EXPOSE 4200 # Serve the app CMD ["npm", "start"] 

主目录的Dockerfile:

 FROM python:3.6.1 ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /code ADD requirements.txt /code/ RUN pip3 install -r requirements.txt ADD . /code/ 

泊坞窗,compose.yml:

 version: '3' services: db: image: postgres environment: POSTGRES_USER: aso POSTGRES_PASSWORD: somepass django: build: . command: python3 MainDirectory/backend/myProject/manage.py runserver 0.0.0.0:8001 volumes: - .:/code ports: - "8001:8001" depends_on: - db angular: build: MainDirectory/frontend ports: - "4200:4200" depends_on: - django 

init.sql:

 CREATE USER myUser; CREATE DATABASE myProject; GRANT ALL PRIVILEGES ON DATABASE myProject TO myUser; 

我想我正在运行相同的问题,也许你应该只使用docker-compose在本地运行你的应用程序,并将其configuration为使用postgres插件在heroku上运行: https : //devcenter.heroku.com/articles/ heroku-postgresql 。

但是我不确定如何在这之后实际上启动应用程序。 我可以使用django命令进行迁移:python manage.py migrate,但是无法使用heroku运行python manage.py runserver启动服务器,因为我正在上传Docker镜像。 所以我不确定如何启动应用程序。 也许附加function可以帮助…

编辑1:解决了Django的应用程序,结帐我的问题: docker+ Django + Postgres的附加组件+ Heroku