我已经使用Docker在Heroku上部署了简单的flask应用程序,并使用Heroku-sample-flask-prod.herokuapp.com进行访问;这里什么都没有。打造令人惊叹的"错误页面。据我所知,在使用herokudns.com时,DNS设置不正确就会发生这种情况。但这里我使用的是herokuapp.com链接。在任何情况下都应该可以访问。那么这里出了什么问题?
烧瓶代码:
import os
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return "welcome to the flask tutorials"
if __name__ == "__main__":
# below arrangment is done specially for Heroku
# https://stackoverflow.com/questions/17260338/deploying-flask-with-heroku
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port, debug = True)
我的Dockerfile
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y libxml2-dev xmlsec1
RUN apt-get install -y python3-pip python3-dev
RUN cd /usr/local/bin
RUN ln -s /usr/bin/python3 python
RUN pip3 --no-cache-dir install --upgrade pip
RUN rm -rf /var/lib/apt/lists/*
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
CMD python3 app.py
我的heroku.yml
build:
docker:
web: Dockerfile
run:
web: python3 app.py
刚刚发生在我身上。
使用Heroku CLI删除应用程序,然后重新创建并推送至Heroku。