From fe53c854473584a91848e4a4ccf11add859b40bf Mon Sep 17 00:00:00 2001 From: puls200 Date: Mon, 16 Oct 2023 15:34:18 +0200 Subject: [PATCH] made simple path change and added documentation pt 1 --- misc/Deployment.md | 43 +++++++++++++++++++++++++++++++++++ src/server/BreCal/local_db.py | 4 ++-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 misc/Deployment.md diff --git a/misc/Deployment.md b/misc/Deployment.md new file mode 100644 index 0000000..abf4930 --- /dev/null +++ b/misc/Deployment.md @@ -0,0 +1,43 @@ +# System deployment + +___ + +## Prerequisites + +## Client + +## Database + +## Backend / Flask app + +In order to not have complicated and error-prone copying manoevers a direct deployment from the repo is used using git. + +### File structure + +### Steps + +1) Created a ssh-key for the user that does the installation on the server following the Github [instructions](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent). +2) Deploy generated key to the Github user account. +3) In the shell, activate ssh-agent and add the key. For example: + +```bash +eval ($ssh-agent) +ssh-add ~/.ssh/od_ed25519 +``` + +4) Change to deployment folder + +```bash +cd /var/www/brecal_test +``` + +5) Perform sparse checkout on the Flask server subtree + +```bash +git clone -n git@github.com:puls200/brecal.git +cd +git sparse-checkout set --no-cone src/server +git checkout +``` + +6) Database credentials are stored outside the web root, we are using /var/www/secure. Here the file ```connection_data.json``` is placed, a different named copy for each instance. diff --git a/src/server/BreCal/local_db.py b/src/server/BreCal/local_db.py index 5b8c631..edecd3b 100644 --- a/src/server/BreCal/local_db.py +++ b/src/server/BreCal/local_db.py @@ -9,7 +9,7 @@ connection_pool = None def initPool(): try: - config_path = './src/server/BreCal/connection_data.json' + config_path = '../../../../secure/connection_data_test.json' print (os.getcwd()) if not os.path.exists(config_path): print ('cannot find ' + config_path) @@ -31,7 +31,7 @@ def initPool(): print(e) def getPoolConnection(): - config_path = './src/server/BreCal/connection_data.json' + config_path = '../../../../secure/connection_data_test.json' f = open(config_path); connection_data = json.load(f) return mysql.connector.connect(**connection_data) \ No newline at end of file