diff --git a/cookiecutter.json b/cookiecutter.json
index f43940c..03cd028 100644
--- a/cookiecutter.json
+++ b/cookiecutter.json
@@ -7,5 +7,6 @@
"project_short_description": "A flasky app.",
"use_pipenv": ["no", "yes"],
"python_version": ["3.7", "3.6"],
- "node_version": ["12", "10", "8"]
+ "node_version": ["12", "10", "8"],
+ "deployment_on_heroku": ["no", "yes"]
}
diff --git a/{{cookiecutter.app_name}}/Pipfile b/{{cookiecutter.app_name}}/Pipfile
index 427b8f2..033e214 100644
--- a/{{cookiecutter.app_name}}/Pipfile
+++ b/{{cookiecutter.app_name}}/Pipfile
@@ -12,6 +12,9 @@ click = ">=5.0"
# Database
Flask-SQLAlchemy = "==2.4.1"
SQLAlchemy = "==1.3.9"
+{%- if cookiecutter.deployment_on_heroku == "yes" %}
+psycopg2 = "==2.8.3"
+{%- endif %}
# Migrations
Flask-Migrate = "==2.5.2"
diff --git a/{{cookiecutter.app_name}}/Procfile b/{{cookiecutter.app_name}}/Procfile
index aaf74ed..56dc581 100644
--- a/{{cookiecutter.app_name}}/Procfile
+++ b/{{cookiecutter.app_name}}/Procfile
@@ -1 +1,2 @@
+release: flask db upgrade
web: gunicorn {{cookiecutter.app_name}}.app:create_app\(\) -b 0.0.0.0:$PORT -w 3
diff --git a/{{cookiecutter.app_name}}/README.rst b/{{cookiecutter.app_name}}/README.rst
index dc15fac..08a6514 100644
--- a/{{cookiecutter.app_name}}/README.rst
+++ b/{{cookiecutter.app_name}}/README.rst
@@ -135,3 +135,56 @@ should cache all your assets forever by including the following line
in your ``settings.py``::
SEND_FILE_MAX_AGE_DEFAULT = 31556926 # one year
+
+
+{%- if cookiecutter.deployment_on_heroku == "yes" %}
+Deployment on Heroku
+--------------------
+
+Before using automatic deployment on Heroku you have to add migrations to your repository.
+You can do it by using following commands ::
+
+ flask db init
+ flask db migrate
+ git add migrations/
+ git commit -m "Add migrations"
+ git commit push
+
+Make sure folder `migrations/versions` is not empty.
+
+Deploy to Heroku button
+^^^^^^^^^^^^^^^^^^^^^^^
+
+.. raw:: html
+
+
+
+
+Heroku CLI
+^^^^^^^^^^
+
+If you want deploy by using Heroku CLI:
+
+* create Heroku App. You can leave your app name, change it or leave it blank (random name will be generated)::
+
+ heroku create {{cookiecutter.app_name}}
+
+* add buildpacks::
+
+ 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)::
+
+ heroku addons:create heroku-postgresql:hobby-dev
+
+* set environmental variables (change secret key)::
+
+ heroku config:set SECRET_KEY=
+ heroku config:set FLASK_APP=autoapp.py
+
+* deploy on Heroku::
+
+ git push heroku master
+
+{%- endif %}
\ No newline at end of file
diff --git a/{{cookiecutter.app_name}}/app.json b/{{cookiecutter.app_name}}/app.json
new file mode 100644
index 0000000..b13ea76
--- /dev/null
+++ b/{{cookiecutter.app_name}}/app.json
@@ -0,0 +1,30 @@
+{
+ "name": "{{cookiecutter.app_name}}",
+ "repository": "https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.app_name}}",
+ "env": {
+ "SECRET_KEY": {
+ "description": "SECRET_KEY.",
+ "generator": "secret"
+ },
+ "FLASK_APP": {
+ "description": "FLASK_APP.",
+ "value": "autoapp.py"
+ }
+ },
+ "buildpacks": [
+ {
+ "url": "heroku/nodejs"
+ },
+ {
+ "url": "heroku/python"
+ }
+ ],
+ "addons": [
+ {
+ "plan": "heroku-postgresql",
+ "options": {
+ "version": "11"
+ }
+ }
+ ]
+}
diff --git a/{{cookiecutter.app_name}}/package.json b/{{cookiecutter.app_name}}/package.json
index 45fb1e2..d6a1f85 100644
--- a/{{cookiecutter.app_name}}/package.json
+++ b/{{cookiecutter.app_name}}/package.json
@@ -7,7 +7,8 @@
"start": "concurrently -n \"WEBPACK,FLASK\" -c \"bgBlue.bold,bgMagenta.bold\" \"npm run webpack-dev-server\" \"npm run flask-server\"",
"webpack-dev-server": "NODE_ENV=debug webpack-dev-server --host=0.0.0.0 --port 2992 --hot --inline",
"flask-server": "{% if cookiecutter.use_pipenv == 'yes' %}pipenv run {% endif %}flask run --host=0.0.0.0",
- "lint": "eslint \"assets/js/*.js\""
+ "lint": "eslint \"assets/js/*.js\"",
+ "postinstall": "npm run build"
},
"repository": {
"type": "git",
diff --git a/{{cookiecutter.app_name}}/requirements/prod.txt b/{{cookiecutter.app_name}}/requirements/prod.txt
index 86f1ffe..4d6b143 100644
--- a/{{cookiecutter.app_name}}/requirements/prod.txt
+++ b/{{cookiecutter.app_name}}/requirements/prod.txt
@@ -8,6 +8,9 @@ click>=7.0
# Database
Flask-SQLAlchemy==2.4.1
SQLAlchemy==1.3.9
+{%- if cookiecutter.deployment_on_heroku == "yes" %}
+psycopg2==2.8.3
+{%- endif %}
# Migrations
Flask-Migrate==2.5.2