Skip to content

Commit e1b6439

Browse files
aviaryanjuslee
authored andcommitted
Updated Heroku docs, fixed heroku build (fossasia#333)
* added runtime.txt * exact python version * added a base level requirements * added migrate command to Procfile * fixed Procfile, run open_event * added updated heroku deploy instructions * updated HowtoDeploytoHeroku.md * updated docs
1 parent c19eaf6 commit e1b6439

File tree

5 files changed

+23
-25
lines changed

5 files changed

+23
-25
lines changed

Procfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
web: gunicorn run:current_app
1+
web: gunicorn open_event:app
2+
migrate: python manage.py db upgrade

docs/HowtoDeploytoHeroku.md

+15-24
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,22 @@
11
# How to deploy server to Heroku
22

3-
Here are the steps:
3+
### Steps
44

5-
* We need to install heroku on our machine.Type the following in your linux terminal:
5+
* We need to install heroku on our machine. Type the following in your linux terminal:
66
* ```wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh```
77
This installs the Heroku Toolbelt on your machine to access heroku from the command line.
8-
* Next we need to login to our heroku server(assuming that you have already created an account).Type the following in the terminal:
8+
* Next we need to login to our heroku server (assuming that you have already created an account). Type the following in the terminal:
99
* ```heroku login```
10-
You will see the following output:
11-
Enter your Heroku credentials.
12-
13-
Password (typing will be hidden):
14-
Logged in as [email protected]
15-
* Once logged in we need to create a space on the heroku server for our application.This is done with the following command
10+
* Enter your credentials and login.
11+
* Once logged in we need to create a space on the heroku server for our application. This is done with the following command
1612
* ```heroku create```
17-
* We need to initialize our git repository and push the master branch of our repository to heroku.Type:
18-
* ```git init```
19-
If the commit isn't changed to master we need to do so by typing the following commands on terminal:
20-
* ```git add -A```
21-
* ```git commit -m "Initial Commit."```
22-
* ```git push origin master```
23-
* Next we create our requirements.txt file using the pip command:
24-
* ```pip freeze > requirements.txt```
25-
* The next step is creating a Procfile. This can be done by using a production ready web server called gunicorn.The contents of the Procfile will be:
26-
* ```web: gunicorn <app>:app```
27-
Here, the <app> will be replaced by the name of the application without the .py at its end.Basically a Procfile tells heroku what to name our process which runs our web application.
28-
* Before deploying to heroku, make sure that the app works locally on the designated port.
29-
* Finally we deploy the code to heroku.Its very simple, just type:
30-
* ```git push heroku master```
31-
At the end of the process a URL will be generated where our flask application will run.
13+
* Once the app is created, now it's time to set the `DATABASE_URL` env var.
14+
* ```heroku config:set DATABASE_URL=postgresql://postgres:start@localhost/test```
15+
* After setting env vars, create the heroku database.
16+
* ```heroku addons:create heroku-postgresql:hobby-dev```
17+
* ```heroku pg:promote <HEROKU_POSTGRESQL_COLOR_URL>```
18+
* Then we deploy the code to heroku.
19+
* ```git push heroku master``` or
20+
* ```git push heroku yourbranch:master``` if you are in a different branch than master
21+
* Finally, time to create tables on the server. Also in case of model updates, run the following command -
22+
* ```heroku run migrate```

open_event/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,7 @@ def request_wants_json():
7979
request.accept_mimetypes['text/html']
8080

8181
current_app, manager, database = create_app()
82+
83+
84+
if __name__ == '__main__':
85+
current_app.run()

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-r requirements/prod.txt

runtime.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-2.7.11

0 commit comments

Comments
 (0)