Closed EdwinB12 closed 5 months ago
@GiorgioCerro @mhauru
Below is a simple script that I am using to deploy a local instance of the app. Also offers the option to restart the database. I don't think we should commit this to the repo but could be handy for development.
#!/bin/bash
# REMEMBER TO ACTIVATE YOUR PYTHON VIRTUAL ENVIRONMENT BEFORE RUNNING THIS SCRIPT!
# THIS SCRIPT SHOULD BE RUN FROM THE ROOT LEVEL OF THE REPOSITORY
# Load the environment variables
source .secrets/dtenv_localdb.sh
# Take in an argument called 'restart-db' to optionally restart the database
if [ "$1" == "restart-db" ]; then
echo "Restarting the database"
# stop and delete server container
docker stop $DT_SQL_DBNAME
docker rm $DT_SQL_DBNAME
# start the postgres docker container
docker run --name $DT_SQL_DBNAME -e POSTGRES_PASSWORD=$DT_SQL_PASS -p 5432:5432 -d $DT_SQL_USER
# create the database
createdb --host $DT_SQL_HOST --username $DT_SQL_USER $DT_SQL_DBNAME -W
fi
# Run the backend. This will run the backend in the background to leave the terminal open for the frontend.
cd dtbase/backend
./run_localdb.sh &
# Run the frontend
cd ../webapp
./run.sh
# NOTE: THE BACKEND WILL CONTINUE TO RUN IN THE BACKGROUND AFTER THE TERMINAL IS CLOSED.
# TO FIND AND KILL THE BACKGORUND PROCESS, RUN ps TO SEE ALL RUNNING PROCESSES AND THEN KILL THE PROCESS WITH IT'S PID ID WITH KILL <PID>