Search code examples
postgresqlherokusqlalchemygunicorn

Heroku Postgres - Build Succeeded and Release Completed BUT Deploy Failed


Background

I'm at the end of my rope. For the last few weeks, I've been on a wild goose chase trying to get my Postgres database on Heroku again. Finally, I ended up scrapping the old one and created a new database from scratch and built everything thing up to where I had it before. This is where I am now.

Error

The Build is successful:

-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/python
-----> Python app detected
-----> Using Python version specified in Pipfile.lock
cp: cannot stat '/tmp/build_0a33f4f6/requirements.txt': No such file or directory
-----> Using cached install of python-3.8.12
-----> Installing pip 21.3.1, setuptools 57.5.0 and wheel 0.37.0
-----> Installing dependencies with Pipenv 2020.11.15
       Installing dependencies from Pipfile.lock (190000)...
-----> Installing SQLite3
-----> Discovering process types
       Procfile declares types -> release, web
-----> Compressing...
       Done: 121.2M
-----> Launching...
 !     Release command declared: this new release will not be available until the command succeeds.
       Released v43
       https://my-example-app.herokuapp.com/ deployed to Heroku

The the release phase begins, and while no error is displayed, I still exit with a status 1 and the app fails deployment to Heroku:

Creating a virtualenv for this project...
Pipfile: /app/Pipfile
Using /app/.heroku/python/bin/python3.8 (3.8.12) to create virtualenv...
  creator CPython3Posix(dest=/app/.local/share/virtualenvs/app-4PlAip0Q, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/app/.local/share/virtualenv)
    added seed packages: pip==21.3.1, setuptools==58.3.0, wheel==0.37.0
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
✔ Successfully created virtual environment! 
Virtualenv location: /app/.local/share/virtualenvs/app-4PlAip0Q
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
Process exited with status 1
State changed from up to complete
Release v40 command failed by user techpriest.gabriel@gmail.com

Pipfile:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
flask = "*"
sqlalchemy = "==1.3.23"
flask-sqlalchemy = "*"
flask-migrate = "*"
flask-swagger = "*"
psycopg2-binary = "*"
python-dotenv = "*"
flask-cors = "*"
gunicorn = "*"
flask-jwt-simple = "*"
datetime = "*"
requests = "*"
pytest = "*"
flask-admin = "*"
pytest-flask = "*"
pytest-flask-sqlalchemy = "*"
cloudinary = "*"
google-cloud-vision = "*"
pyfcm = "*"
postgres = "*"
pytz = "*"
pandas = "*"
xlrd = "*"
openpyxl = "*"
pyjwt = "*"

[requires]
python_version = "3.8"

[scripts]
start="flask run -p 3000 --host=0.0.0.0"
init="flask db init"
migrate="flask db migrate"
upgrade="flask db upgrade"

procfile

release: pipenv run upgrade
web: gunicorn wsgi --chdir ./src/

wsgi.py

# This file was created to run the application on heroku using gunicorn.
# Read more about it here: https://devcenter.heroku.com/articles/python-gunicorn

from main import app as application

if __name__ == "__main__":
    application.run()

Solution

  • I solved this problem with edit my procfile, you need to remove release: pipenv run upgrade from your procfile and try again, you can upgrade pipenv using heroku cli and another way you can use virtualenv.Good Luck!