Basically a customized version of Miguel Grinberg's excellent Flask tutorial. A web version (yucK!) of Gretchen Rubin's One-Sentence Journal.
- Create a virtual environment:
python3 -m venv venv
- Activate it:
source venv/bin/activate
- Upgrade pip:
pip install --upgrade pip
- Install requirements:
pip install -r requirements.txt
- Inintialize the database:
flask db init
- Create migrations:
flask db migrate
- Run the migrations:
flask db upgrade
- Create an
.env
file and add the lineFLASK_ENV=development
- Run the server:
flask run
- Start a fake SMTP server:
python -m smtpd -n -c DebuggingServer localhost:8025
- Make sure
FLASK_DEBUG=0
- Put
MAIL_SERVER=localhost
andMAIL_PORT=8025
in your.env
file
- Connect to MySQL as your custom user (see Ansible branch):
mysql -u [someusername] -p
(enter your password when prompted) - Create the new database:
create database journalito character set utf8 collate utf8_bin;
- Create a user for this specific application/database:
create user 'journalito'@'localhost' identified by 'SOMEGOODPASSWORD';
- Grant this new user privileges:
grant all privileges on journalito.* to 'journalito'@'localhost';
- Reload/flush privileges:
flush privileges;
- Exit MySQL:
quit;
Make sure you're in the correct user's home directory (see Ansible branch), then:
mkdir src && cd src
git clone [repo URL]
cd journalito
- Set up your virtual environment:
python3 -m venv venv
- Activate your venv:
source venv/bin/activate
- Install core packages:
pip install -r requirements.txt
Note! If the above throws erorrs like error: invalid command 'bdist_wheel'
:
a. Deactivate the venv: deactivate
b. Delete the venv
directory: rm -r venv
c. Repeat steps 4 and 5 above, then before step 6, run: pip install wheel
- Install production packages:
pip install -r requirements-prod.txt
- Get the database in order:
flask db upgrade
- Configure supervisor to run the application privately on port 8000:
[program:journalito]
command=/home/deployer/src/journalito/venv/bin/gunicorn -b localhost:8000 -w 4 journalito:flapp
directory=/home/deployer/src/journalito
user=deployer
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
- Set up an SSL cert TODO
- Configure nginx TODO
- Get the new code:
git pull
- Stop the server real quick:
sudo supervisorctl stop journalito
- Update the db:
flask db upgrade
- Start ye olde server back up:
sudo supervisorctl start journalito