我正在尝试使用heroku.yml将docker容器部署到heroku。挑战在于缺乏文件和反馈The official documents不足以找出可能造成部署障碍的原因
heroku日志中显示的错误似乎是gunicorn错误
usage: gunicorn [OPTIONS] [APP_MODULE]
gunicorn: error: unrecognized arguments: beatthemarket.run_app:app
如您所见,当前目录是正确的,因此它应该在中找到run_app.py。我不明白为什么beatthemarket.run_app:app
没有被识别
此应用程序使用docker-compose up
在本地运行,没有问题。要在heroku上成功部署,应该更改哪些内容
2020-05-11T05:07:58.017936+00:00 app[web.1]: drwx------ 7 u57155 dyno 4096 May 11 05:02 .
2020-05-11T05:07:58.017936+00:00 app[web.1]: drwx------ 1 u57155 dyno 4096 May 11 05:02 ..
2020-05-11T05:07:58.017937+00:00 app[web.1]: -rw------- 1 u57155 dyno 0 May 11 05:02 __init__.py
2020-05-11T05:07:58.017937+00:00 app[web.1]: -rw------- 1 u57155 dyno 5167 May 11 05:02 app.py
2020-05-11T05:07:58.017937+00:00 app[web.1]: drwx------ 6 u57155 dyno 4096 May 11 05:02 blueprints
2020-05-11T05:07:58.017937+00:00 app[web.1]: drwx------ 3 u57155 dyno 4096 May 11 05:02 build
2020-05-11T05:07:58.017937+00:00 app[web.1]: -rw------- 1 u57155 dyno 224 May 11 05:02 celery_app.py
2020-05-11T05:07:58.017938+00:00 app[web.1]: drwx------ 2 u57155 dyno 4096 May 11 05:02 dist
2020-05-11T05:07:58.017938+00:00 app[web.1]: -rw------- 1 u57155 dyno 479 May 11 05:02 extensions.py
2020-05-11T05:07:58.017938+00:00 app[web.1]: -rw------- 1 u57155 dyno 60 May 11 05:02 run_app.py
2020-05-11T05:07:58.017938+00:00 app[web.1]: drwx------ 5 u57155 dyno 4096 May 11 05:02 templates
2020-05-11T05:07:58.017938+00:00 app[web.1]: drwx------ 6 u57155 dyno 4096 May 11 05:02 tests
Heroku日志
2020-05-11T05:06:54.212285+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-11T05:06:53.000000+00:00 app[api]: Build succeeded
2020-05-11T05:06:53.700561+00:00 app[api]: Release v19 created by user
2020-05-11T05:06:53.700561+00:00 app[api]: Deploy 0841aad1 by user
2020-05-11T05:07:27.616057+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-11T05:07:27.619985+00:00 heroku[web.1]: State changed from crashed to starting
2020-05-11T05:07:27.516837+00:00 app[web.1]: usage: gunicorn [OPTIONS] [APP_MODULE]
2020-05-11T05:07:27.516849+00:00 app[web.1]: gunicorn: error: unrecognized arguments: beatthemarket.run_app:app
2020-05-11T05:07:27.223891+00:00 app[web.1]: total 48
2020-05-11T05:07:27.223900+00:00 app[web.1]: drwx------ 7 u12323 dyno 4096 May 11 05:02 .
2020-05-11T05:07:27.223900+00:00 app[web.1]: drwx------ 1 u12323 dyno 4096 May 11 05:02 ..
2020-05-11T05:07:27.223901+00:00 app[web.1]: -rw------- 1 u12323 dyno 0 May 11 05:02 __init__.py
2020-05-11T05:07:27.223901+00:00 app[web.1]: -rw------- 1 u12323 dyno 5167 May 11 05:02 app.py
2020-05-11T05:07:27.223902+00:00 app[web.1]: drwx------ 6 u12323 dyno 4096 May 11 05:02 blueprints
2020-05-11T05:07:27.223902+00:00 app[web.1]: drwx------ 3 u12323 dyno 4096 May 11 05:02 build
2020-05-11T05:07:27.223903+00:00 app[web.1]: -rw------- 1 u12323 dyno 224 May 11 05:02 celery_app.py
2020-05-11T05:07:27.223903+00:00 app[web.1]: drwx------ 2 u12323 dyno 4096 May 11 05:02 dist
2020-05-11T05:07:27.223903+00:00 app[web.1]: -rw------- 1 u12323 dyno 479 May 11 05:02 extensions.py
2020-05-11T05:07:27.223904+00:00 app[web.1]: -rw------- 1 u12323 dyno 60 May 11 05:02 run_app.py
2020-05-11T05:07:27.223904+00:00 app[web.1]: drwx------ 5 u12323 dyno 4096 May 11 05:02 templates
2020-05-11T05:07:27.223905+00:00 app[web.1]: drwx------ 6 u12323 dyno 4096 May 11 05:02 tests
2020-05-11T05:07:58.391881+00:00 heroku[web.1]: State changed from starting to crashed
2020-05-11T05:07:58.276177+00:00 app[web.1]: usage: gunicorn [OPTIONS] [APP_MODULE]
2020-05-11T05:07:58.276256+00:00 app[web.1]: gunicorn: error: unrecognized arguments: beatthemarket.run_app:app
2020-05-11T05:07:58.017926+00:00 app[web.1]: total 48
2020-05-11T05:07:58.017936+00:00 app[web.1]: drwx------ 7 u57155 dyno 4096 May 11 05:02 .
2020-05-11T05:07:58.017936+00:00 app[web.1]: drwx------ 1 u57155 dyno 4096 May 11 05:02 ..
2020-05-11T05:07:58.017937+00:00 app[web.1]: -rw------- 1 u57155 dyno 0 May 11 05:02 __init__.py
2020-05-11T05:07:58.017937+00:00 app[web.1]: -rw------- 1 u57155 dyno 5167 May 11 05:02 app.py
2020-05-11T05:07:58.017937+00:00 app[web.1]: drwx------ 6 u57155 dyno 4096 May 11 05:02 blueprints
2020-05-11T05:07:58.017937+00:00 app[web.1]: drwx------ 3 u57155 dyno 4096 May 11 05:02 build
2020-05-11T05:07:58.017937+00:00 app[web.1]: -rw------- 1 u57155 dyno 224 May 11 05:02 celery_app.py
2020-05-11T05:07:58.017938+00:00 app[web.1]: drwx------ 2 u57155 dyno 4096 May 11 05:02 dist
2020-05-11T05:07:58.017938+00:00 app[web.1]: -rw------- 1 u57155 dyno 479 May 11 05:02 extensions.py
2020-05-11T05:07:58.017938+00:00 app[web.1]: -rw------- 1 u57155 dyno 60 May 11 05:02 run_app.py
2020-05-11T05:07:58.017938+00:00 app[web.1]: drwx------ 5 u57155 dyno 4096 May 11 05:02 templates
2020-05-11T05:07:58.017938+00:00 app[web.1]: drwx------ 6 u57155 dyno 4096 May 11 05:02 tests
2020-05-11T05:07:59.771430+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=beatthemarket.herokuapp.com request_id=6e20fadf-1671-461d-b287-c7de6496d3b1 fwd="24.209.151.152" dyno= connect= service= status=503 bytes= protocol=https
2020-05-11T05:08:00.757177+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=beatthemarket.herokuapp.com request_id=29d0c500-b683-40a4-b9ba-8be784d9a0e6 fwd="24.209.151.152" dyno= connect= service= status=503 bytes= protocol=https
2020-05-11T05:08:40.523123+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=beatthemarket.herokuapp.com request_id=4c65003a-ef2d-45e8-a789-d799ec8e1d21 fwd="24.209.151.152" dyno= connect= service= status=503 bytes= protocol=https
2020-05-11T05:08:41.374071+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=beatthemarket.herokuapp.com request_id=c23f15cd-5c52-463e-9704-2ea3b529e3a7 fwd="24.209.151.152" dyno= connect= service= status=503 bytes= protocol=https
^C
运行应用程序py
from beatthemarket.app import create_app
app = create_app()
Dockerfile
FROM python:3.7.5-slim-buster
RUN apt-get update && apt-get install -qq -y \
build-essential libpq-dev --no-install-recommends
ENV INSTALL_PATH /beatthemarket
RUN mkdir -p $INSTALL_PATH
WORKDIR ${INSTALL_PATH}
COPY . .
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
RUN pip install --editable .
CMD gunicorn -c "python:config.gunicorn" "beatthemarket.run_app:app"
docker compose.yml
version: '2'
services:
postgres:
image: 'postgres:9.5'
env_file:
- '.env'
volumes:
- 'postgres:/var/lib/postgresql/data'
ports:
- '5432:5432'
command: ["postgres", "-c", "log_statement=all"]
redis:
image: 'redis:3.0-alpine'
command: redis-server --requirepass devpassword
volumes:
- 'redis:/var/lib/redis/data'
ports:
- '6379:6379'
website:
build: .
command: >
gunicorn -c python:config.gunicorn
--workers 3
--log-level=debug
--access-logfile -
--reload
beatthemarket.run_app:app
run:app
env_file:
- '.env'
volumes:
- '.:/beatthemarket'
ports:
- '8000:8000'
celery:
build: .
command: celery worker -l debug -A beatthemarket.celery_app:app
env_file:
- '.env'
volumes:
- '.:/beatthemarket'
volumes:
postgres:
redis:
heroku.yml
build:
docker:
postgres: postgres/Dockerfile
redis: redis/Dockerfile
web: Dockerfile
run:
postgres: postgres -c log_statement=all
redis: redis-server --requirepass devpassword
celery:
command:
- celery worker -l debug -A beatthemarket.celery_app:app
image: web
web: >
ls -la beatthemarket && gunicorn -c python:config.gunicorn \
--bind 0.0.0.0:$PORT wsgi \
--workers 3 \
--log-level=debug \
--access-logfile - \
--reload \
beatthemarket.run_app:app
目前没有回答
相关问题 更多 >
编程相关推荐