Installation and Deployment Guide
Before Starting the Installation
The quickest way to use LCDA is to directly visit the official website of LCDA.
However, if you want to deploy your own LCDA, it is essential to ensure that you can create and configure the following instances: Google Cloud Run, Google Cloud Storage, and a publicly accessible database such as Amazon RDS.
Please note that deploying LCDA in the cloud requires a certain level of technical expertise, and it is recommended that you have experience with cloud services before attempting to deploy LCDA on your own.
Prerequisites
Miniconda v23.1.0+ or Anaconda v23.1.0+ if you use
Condavirtual environmentPython v3.7+ if you use
venvvirtual environmentGit v2.30+
Installation and Deployment Steps
This section will help you step by step from scratch to deploying the LCDA platform.
Create and change into a new directory
mkdir COMP208-202223-Team16 cd COMP208-202223-Team16Pull source code
git clone https://github.com/COMP208-Team-16-2022-23/Group-Project-Code.gitChange into project directory
cd Group-Project-CodeCreate and activate a Python virtual environment
You can choose either
venvorcondato create a virtual environment.
TIP
venvenvironment is suitable for short-term testing and can be deleted along with the project folder without affecting the system environment.condaenvironment is suitable for long-term development as it offers more comprehensive package management and environment management functions.
venv virtual environment
This command will create a virtual environment in the current directory.
python -m venv .
Activate the virtual environment
source ./bin/activate
.\Scripts\activate.bat
Install the required packages
pip install -r requirements.txt
Conda virtual environment
Create a Conda virtual environment named COMP208 with Python version 3.10.
conda env create -f ./misc/environment.yml
Activate Conda virtual environment
conda activate COMP208
Configure cloud services
LCDA was originally designed to be deployed in the cloud. Therefore, configuring cloud services is an essential part of running LCDA smoothly. For each cloud service configuration tutorial, please refer to its official documentation, which will not be repeated in this article.
Amazon RDS: LCDA uses Amazon RDS to host the website database. Detailed database configuration tutorials can be found in the official documentation. However, users can also choose other cloud hosting service providers for their database needs.
Google Cloud Storage: LCDA uses Google Cloud Storage as the storage server for the website. Detailed tutorials on using Google Cloud Storage can be found in the official documentation.
Google Cloud Run: LCDA uses Google Cloud Run to host and deploy the website. A detailed tutorial on using Google Cloud Run can be found in the official documentation.
Do not worry, many cloud service providers offer users a certain amount of free trial quota. If LCDA is only used for testing, there will be no additional expenses.
Configure
/secret.pyBefore you can deploy and run LCDA, you need to configure the
/secret.pyfile with relevant information. This file contains sensitive information such as API keys, database passwords, and other secrets that are required for the proper functioning of the application. In this case, it also includes relevant Google Cloud information.The following is an example of configuring
/secret.py:from datetime import timedelta # DOMAIN DOMAIN = 'Your google cloud run domain' SECRET_KEY = 'Your secret key (i.e. a random string)' PERMANENT_SESSION_LIFETIME = timedelta(minutes=45) # Configuration for the database HOSTNAME = 'Your database hostname' PORT = 'Your database port' DATABASE = 'Your database name' USERNAME = 'Your database account username' PASSWORD = 'Your database account password' LOCAL_TEST = False # set to True will ignore the above configuration and use local sqlite database called project.db # Configuration variables for email # configure the mail settings MAIL_SERVER = 'Your email server' MAIL_PORT = 465 # Your email server port MAIL_USE_SSL = True # Whether your email server uses SSL MAIL_USERNAME = 'Your email address' MAIL_PASSWORD = 'Your email account password' MAIL_DEFAULT_SENDER = 'LCDA Team' MAIL_MAX_EMAILS = None # Configuration variables for Google Cloud Storage GOOGLE_APPLICATION_CREDENTIALS = { # Your service account key, in json format. } BUCKET_NAME = 'Your Google Cloud Storage bucket name'Deploy LCDA locally
export FLASK_APP=app.py export FLASK_ENV=development flask runset FLASK_APP=app.py set FLASK_ENV=development flask run$env:FLASK_APP = "app.py" $env:FLASK_ENV = "development" flask run
You're done! Now you can visit http://127.0.0.1:5000 in your browser to access LCDA.