Clone
4
deployment instructions
Harley edited this page 2026-04-03 21:08:07 +00:00

Advanced users may have their own ways of deploying flask, it's entirely up to personal preference. This is the method we are using. It requires manually starting the server, so be sure to do that should the machine be disconnected/rebooted. There is possibly a way to set up a cronjob, which we may investigate in the future.

We use tmux to manage flask in a separate window from our main tasks.

Create a new tmux window:

tmux new -s myriad

To detach from a tmux window at any time, press CTRL+B followed by D.

To re-attach to a tmux window:

tmux attach -t myriad

To list active tmux sessions:

tmux ls

Myriad Installation

It's good practice to ensure the system is up to date

sudo apt-get update
sudo apt upgrade

Clone Myriad, create the virtual environment, and activate the virtual environment

git clone https://tea.cubes.link/cube/myriad.git 
cd myriad
python3 -m venv venv
source venv/bin/activate

Install necessary packages (make sure the virtual environment has been activated)

pip install flask
pip install waitress

Prepare all the directories used by Myriad to store assets

mkdir instance
mkdir myriad/static/icons
mkdir myriad/static/blinkies
mkdir myriad/static/stamps
mkdir myriad/static/tmp

Copy this default configuration:

REGISTRATION = True # Make sure to disable in production after setting up first user!!!
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'}
ICON_UPLOAD_FOLDER = 'myriad/static/icons'
BLINKIES_UPLOAD_FOLDER = 'myriad/static/blinkies'
STAMPS_UPLOAD_FOLDER = 'myriad/static/stamps' 
THEMES_FOLDER = 'myriad/static/themes' 
TMP_FOLDER = 'myriad/static/tmp' 

Create the config file:

sudo nano instance/config.py

Then paste! Now save and exit.

Generate a secret key, highlight it, and copy to the clipboard

python -c 'import secrets; print(secrets.token_hex())'

Go back to the config file, and create a new line:

sudo nano instance/config.py

SECRET_KEY = '(paste generated key here)'

Save and close the config file. Still in the tmux window and virtual environment, initialize the database:

flask --app myriad init-db

Start waitress. Use port 80 for serving over http directly, or 5000 if you are going to follow the upcoming instructions for a reverse proxy.

waitress-serve --port=5000 --call 'myriad:create_app'

Go to a web browser, to the IP address of your server followed by the port (unless using 80, in which case no port is required, OR unless you are going to set up the reverse proxy before continuing. This might be a good idea if you are concerned about encryption while registering the first account). Navigate to Register and set up a username and password for at least one administrator account. Once this has been done, come back to the server, stop waitress with CTRL+C, and edit the config file to disable registration.

sudo nano instance/config.py

REGISTRATION = False

The login and registration links will now be removed, and you will need to go to /auth/login to login to Myriad. /auth/registration will no longer be accessible. The site is now ready to be used! We strongly recommend following the instructions to set up nginx as a reverse proxy and obtaining a certificate to serve Myriad over https, for your personal security.

Updating Myriad

WARNING: Before updating ALWAYS go to the administration settings page to back up your entire system to a downloadable zip file, so that your data can be restored if the database schema is updated. It is always a good idea to check the repository for commits, and their notes, to see what's been updated, but I would still strongly recommend against updating Myriad without first backing up your data.

Stop waitress with CTRL+C, pull from gitea, then restart waitress.

git pull
waitress-serve --port=5000 --call 'myriad:create_app'

If you need to re-init the database for an update

git pull
flask --app myriad init-db
sudo nano instance/config.py
REGISTRATION = True

Then go to the site and re-make admin account

sudo nano instance/config.py
REGISTRATION = False
waitress-serve --port=5000 --call 'myriad:create_app'

413: Request Entity Too Large (nginx)

This will most likely occur if you have uploaded a lot of images to the site. You will need to edit your nginx config to allow you to upload large files. I would run these commands from outside of the tmux window, just so I can easily access my last used myriad server commands later. Otherwise, it doesn't matter where you do this.

sudo nano /etc/nginx/nginx.conf

Within the http section, add

client_max_body_size 100M;

Save and exit, then reload nginx.

nginx -s reload

Config

Here's the default configuration again, if you need it.

REGISTRATION = True # Make sure to disable in production
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif'} 
ICON_UPLOAD_FOLDER = 'myriad/static/icons' 
BLINKIES_UPLOAD_FOLDER = 'myriad/static/blinkies' 
STAMPS_UPLOAD_FOLDER = 'myriad/static/stamps' 
THEMES_FOLDER = 'myriad/static/themes'
TMP_FOLDER = 'myriad/static/tmp'