Dash App ready to deploy to Heroku π» π β‘οΈ π π€
Credit @amber-luzar - GB Hockey.
Use this template to create a new personal Github repo.
-
Click
Use this Template
. -
Create your new Personal Repository from this template.
Instructions for running the solution locally.
- Clone your repo locally.
$ git clone <github_url> dash_template
$ cd dash_template
- Install
Pipenv
(if you havn't already).
$ pip install --user pipenv
- Install project dependencies via
requirements.txt
.
$ pipenv install
- Serve the App.
$ pipenv run python app.py
- Finally, visit the local port that the app is serving on, via your browser: http://127.0.0.1:8050/.
β οΈ Quit ServingIt's good practice to manually quit serving things that are long running, e.g. when you serve the dash app, it will be running and listening on a local port until you stop serving it. If we quit the local server unexpectedly, it may block that port until we restart out machines. To quit serving simply use the
control + C
keys and you should see your command prompt return.
Deploying your app to Heroku.
- Get ready for production! First, we'll want to create a new
requirements.txt
file to reflect our current project's dependencies. So we'll remove the currrent one and getpipenv
to generate a new one.
$ rm requirements.txt
$ pipenv lock -r > requirements.txt
- Add
Procfile
...this file will tell Heroku how to start your Dash App withgunicorn
(this should actually already be there).
web: gunicorn app:server
-
Create a new Heroku App. Give it a name and select a relevant region (one close to you or your client).
-
Link your Project's Github repo to your Heroku App. Be sure to enable automatic deploys once you link your Github repo. This way, every time you push new commits to your Github repo, Heroku will automatically rebuild your app with the changes.
Note: You may optionally place your app in a development pipeline. To do so, simply click the Choose a pipeline
dropdown and create a new one. Create a staging
and a production
app. Now everytime you make changes to your app, it will be deployed to the staging
app where you can test and debug your changes. When you see all is well, you can simply promote the changes to your production
app, which is the one everyone will be visiting.
β οΈ Environment VariablesIf you are using Dash Auth, make sure you are following the correct procedures for using environment variables locally and adding environment variables in Heroku. It's important you don't simply hard code the actual
VALID_USERNAME_PASSWORD_PAIRS
dictionary and rather get it from the Environment (wether it be locally or in Heroku)!
- Push your project to Github!
$ git add .
$ git commit -m "mvp"
$ git push
Note: You can watch Heroku build your app, just click view build
! Otherwise, click the overview tab and wait for a deployed message.
See
contributing.md