fixup! Add heroku deployment feature

master
Tobiasz Kędzierski 5 years ago committed by James Curtin
parent 6264b22311
commit 2c71459398
  1. 2
      cookiecutter.json
  2. 4
      hooks/post_gen_project.py
  3. 4
      {{cookiecutter.app_name}}/Pipfile
  4. 12
      {{cookiecutter.app_name}}/README.rst
  5. 2
      {{cookiecutter.app_name}}/app.json
  6. 4
      {{cookiecutter.app_name}}/requirements/prod.txt

@ -8,5 +8,5 @@
"use_pipenv": ["no", "yes"], "use_pipenv": ["no", "yes"],
"python_version": ["3.7", "3.6"], "python_version": ["3.7", "3.6"],
"node_version": ["12", "10", "8"], "node_version": ["12", "10", "8"],
"deployment_on_heroku": ["no", "yes"] "use_heroku": ["no", "yes"]
} }

@ -10,6 +10,7 @@ import sys
def clean_extra_package_management_files(): def clean_extra_package_management_files():
"""Removes either requirements files and folder or the Pipfile.""" """Removes either requirements files and folder or the Pipfile."""
use_pipenv = "{{cookiecutter.use_pipenv}}" use_pipenv = "{{cookiecutter.use_pipenv}}"
use_heroku = "{{cookiecutter.use_heroku}}"
to_delete = [] to_delete = []
if use_pipenv == "yes": if use_pipenv == "yes":
@ -17,6 +18,9 @@ def clean_extra_package_management_files():
else: else:
to_delete.append("Pipfile") to_delete.append("Pipfile")
if use_heroku == "no":
to_delete = to_delete + ["Procfile", "app.json"]
try: try:
for file_or_dir in to_delete: for file_or_dir in to_delete:
if os.path.isfile(file_or_dir): if os.path.isfile(file_or_dir):

@ -12,8 +12,8 @@ click = ">=5.0"
# Database # Database
Flask-SQLAlchemy = "==2.4.1" Flask-SQLAlchemy = "==2.4.1"
SQLAlchemy = "==1.3.9" SQLAlchemy = "==1.3.9"
{%- if cookiecutter.deployment_on_heroku == "yes" %} {%- if cookiecutter.use_heroku == "yes" %}
psycopg2 = "==2.8.3" psycopg2-binary = "==2.8.3"
{%- endif %} {%- endif %}
# Migrations # Migrations

@ -136,8 +136,8 @@ in your ``settings.py``::
SEND_FILE_MAX_AGE_DEFAULT = 31556926 # one year SEND_FILE_MAX_AGE_DEFAULT = 31556926 # one year
{%- if cookiecutter.use_heroku == "yes" %}
{%- if cookiecutter.deployment_on_heroku == "yes" %}
Deployment on Heroku 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/nodejs
heroku buildpacks:add --index=1 heroku/python 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 heroku config:set FLASK_APP=autoapp.py
* deploy on Heroku:: * deploy on Heroku::

@ -21,7 +21,7 @@
], ],
"addons": [ "addons": [
{ {
"plan": "heroku-postgresql", "plan": "heroku-postgresql:hobby-dev",
"options": { "options": {
"version": "11" "version": "11"
} }

@ -8,8 +8,8 @@ click>=7.0
# Database # Database
Flask-SQLAlchemy==2.4.1 Flask-SQLAlchemy==2.4.1
SQLAlchemy==1.3.9 SQLAlchemy==1.3.9
{%- if cookiecutter.deployment_on_heroku == "yes" %} {%- if cookiecutter.use_heroku == "yes" %}
psycopg2==2.8.3 psycopg2-binary==2.8.3
{%- endif %} {%- endif %}
# Migrations # Migrations

Loading…
Cancel
Save