From 0ec29787a0cb84678d080a5a9ce0360eef3f59d7 Mon Sep 17 00:00:00 2001 From: cube Date: Tue, 31 Mar 2026 22:09:37 +0000 Subject: [PATCH] Add deployment instructions --- deployment-instructions.md | 139 +++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 deployment-instructions.md diff --git a/deployment-instructions.md b/deployment-instructions.md new file mode 100644 index 0000000..da20400 --- /dev/null +++ b/deployment-instructions.md @@ -0,0 +1,139 @@ +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' +``` + + +# 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' +``` \ No newline at end of file