diff --git a/cookiecutter.json b/cookiecutter.json index 03cd028cf9fa165786166dddc66a453bf8e8bb19..075e5e5b07131b4009f2baed642d4b9dd3e44456 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -8,5 +8,5 @@ "use_pipenv": ["no", "yes"], "python_version": ["3.7", "3.6"], "node_version": ["12", "10", "8"], - "deployment_on_heroku": ["no", "yes"] + "use_heroku": ["no", "yes"] } diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 1bd084e8d3b05e1ac2b305b321d074aa8eea21da..08be14f950c0ae04bd358518c125bdcf356fe980 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -10,6 +10,7 @@ import sys def clean_extra_package_management_files(): """Removes either requirements files and folder or the Pipfile.""" use_pipenv = "{{cookiecutter.use_pipenv}}" + use_heroku = "{{cookiecutter.use_heroku}}" to_delete = [] if use_pipenv == "yes": @@ -17,6 +18,9 @@ def clean_extra_package_management_files(): else: to_delete.append("Pipfile") + if use_heroku == "no": + to_delete = to_delete + ["Procfile", "app.json"] + try: for file_or_dir in to_delete: if os.path.isfile(file_or_dir): diff --git a/{{cookiecutter.app_name}}/Pipfile b/{{cookiecutter.app_name}}/Pipfile index 033e21464e54d00d59dcba659b8bb2fb43bc0d56..f276acb9de4ea27f52bedffe06199e6cc41eb0e7 100644 --- a/{{cookiecutter.app_name}}/Pipfile +++ b/{{cookiecutter.app_name}}/Pipfile @@ -12,8 +12,8 @@ click = ">=5.0" # Database Flask-SQLAlchemy = "==2.4.1" SQLAlchemy = "==1.3.9" -{%- if cookiecutter.deployment_on_heroku == "yes" %} -psycopg2 = "==2.8.3" +{%- if cookiecutter.use_heroku == "yes" %} +psycopg2-binary = "==2.8.3" {%- endif %} # Migrations diff --git a/{{cookiecutter.app_name}}/README.rst b/{{cookiecutter.app_name}}/README.rst index 08a65149d5d8ceef564e4b89ee3ccc5cd0f2d2f6..900207035a568e596077b21549536a98d08e2c09 100644 --- a/{{cookiecutter.app_name}}/README.rst +++ b/{{cookiecutter.app_name}}/README.rst @@ -136,8 +136,8 @@ in your ``settings.py``:: SEND_FILE_MAX_AGE_DEFAULT = 31556926 # one year +{%- if cookiecutter.use_heroku == "yes" %} -{%- if cookiecutter.deployment_on_heroku == "yes" %} Deployment on Heroku -------------------- @@ -174,13 +174,15 @@ If you want deploy by using Heroku CLI: heroku buildpacks:add --index=1 heroku/nodejs heroku buildpacks:add --index=1 heroku/python -* add Postgres database addon (it also sets `DATABASE_URL` environmental variable to created database):: +* add database addon which sets Postgres in version 11 in free `hobby-dev` plan (https://elements.heroku.com/addons/heroku-postgresql#hobby-dev) (it also sets `DATABASE_URL` environmental variable to created database):: - heroku addons:create heroku-postgresql:hobby-dev + heroku addons:create heroku-postgresql:hobby-dev --version=11 -* set environmental variables (change secret key):: +* set environmental variables: change secret key. + `DATABASE_URL` environmental variable is set by database addon in previous step. + Please check `.env.example` to get overview which environmental variables are used in project.:: - heroku config:set SECRET_KEY=<secret-key> + heroku config:set SECRET_KEY=not-so-secret heroku config:set FLASK_APP=autoapp.py * deploy on Heroku:: diff --git a/{{cookiecutter.app_name}}/app.json b/{{cookiecutter.app_name}}/app.json index b13ea76c83e2632c7ea9bb5ed4cae624a706e247..71081d806227b38bca8cbb9c1474f6d51c50561a 100644 --- a/{{cookiecutter.app_name}}/app.json +++ b/{{cookiecutter.app_name}}/app.json @@ -21,7 +21,7 @@ ], "addons": [ { - "plan": "heroku-postgresql", + "plan": "heroku-postgresql:hobby-dev", "options": { "version": "11" } diff --git a/{{cookiecutter.app_name}}/requirements/prod.txt b/{{cookiecutter.app_name}}/requirements/prod.txt index 4d6b143853d5974aed77606eb4788d7f6f855a88..ba2b665228bb210415644511a5b70be35f96808e 100644 --- a/{{cookiecutter.app_name}}/requirements/prod.txt +++ b/{{cookiecutter.app_name}}/requirements/prod.txt @@ -8,8 +8,8 @@ click>=7.0 # Database Flask-SQLAlchemy==2.4.1 SQLAlchemy==1.3.9 -{%- if cookiecutter.deployment_on_heroku == "yes" %} -psycopg2==2.8.3 +{%- if cookiecutter.use_heroku == "yes" %} +psycopg2-binary==2.8.3 {%- endif %} # Migrations