-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
In general there are multiple ways to install MyFestival on a server. Detailed guides for deployment on Linux, Heroku and Docker are part of Miguel Grinberg's Flask Mega-Tutorial:
- Deployment on Linux: Chapter 17
- Deployment on Heroku: Chapter 18
- Deployment on Docker Container: Chapter 19
If you want to deploy the app on your own Linux server please note, that using Postgres instead of MySQL is recommended!
This article focuses on the specific deployment details of MyFestival on Heroku. It is possible to connect your Heroku account directly with Github. However, since this is not mandatory, we will focus on deployment via the Heroku CLI.
First of all you need to set up the repository on the machine from which you are deploying the app:
git clone https://github.com/olk90/myfestival.git
cd myfestival
git checkout <tag>
The <tag>
to check out is the version of the app, you want to deploy (s.
current releases). It is
recommended to deploy always the latest version!
In the following sections you will find a detailed description of the whole configuration necessary to deploy the app to Heroku.
Most of the steps are automated by the script prepare_heroku.sh
in the
repository.
./prepare_heroku.sh <unique-name> <region>
The <unique-name>
must be replaced with a unique name, since it will be part
of the application's URL https://<unique-name>.herokuapp.com/
. The <region>
must be either eu
or us
.
After executing the script, you can continue with the deployment.
heroku apps:create <unique-name> --region eu
As mentioned in the last section, the <unique-name>
must be replaced with a
unique name. Also the region
flag is optional, but if it was not set, the
default region (US) will be used.
To use Postgres in Heroku you need to add the plugin first. This command will
also set the environment variable DATABASE_URL
which is needed by the
application to access the database.
heroku addons:add heroku-postgresql:hobby-dev
As mentioned in Miguel's blog post, the database URL expected by SQL Alchemy has
another prefix, than the one used by Heroku. Therefore you need to set a
variable PLATFORM
to the value HEROKU
, so the prefix can be replaced by the
app itself:
heroku config:set PLATFORM=HEROKU
Setting this environment varaible will also configure the application's logger
which is done in the blog post by setting the variable LOG_TO_STDOUT
!
The following code block contains all other environment variables necessary to run the application:
### initial password for the admin account. CHANGE IMMEDIATELY AFTER FIRST LOGIN!
heroku config:set INITIAL_ADMIN_PW=<password_of_your_choice>
### run the flask commands from Procfile
heroku config:set FLASK_APP=myfestival.py
### set secret key
heroku config:set SECRET_KEY=<random string, that is hard to guess>
To set the SECRET_KEY
it is recommended, to use any random string generator.
During preparations a specific version tag has been checked out from the repository. In order to deploy the app, the repository must be on a branch, which is created by the following command:
git checkout -b deploy
After that the change must be pushed to Heroku by exectuting
git push heroku deploy:main
For further information please check out former mentioned blogpost.
After the deployment succeeded the app will be available under the URL
https://<unique-name>.herokuapp.com/
(depending on the unique name chosen
during the initialization).
The Procfile triggers the creation of an inital admin account named admin
. The
initial password for this accound has been set in the environment variable
INITIAL_ADMIN_PW
. It is recommended, that you change this password immediately
after the first login. The account's name might be changed as well. Find more
information about that in the Account Management guide.