irongit
rango/dev
55 lines1.5 KB
1#!/bin/bash
2# For development only
3
4# if venv doesn't exist, create it
5if [ ! -d "venv" ]; then
6 python -m venv venv
7 # add NGINX_HOST and DOMAIN to venv/Scripts/activate
8 echo "export NGINX_HOST=localhost" >> venv/Scripts/activate
9 echo "export DOMAIN=localhost" >> venv/Scripts/activate
10 echo "export POSTGRES_USER=postgres" >> venv/Scripts/activate
11 echo "export POSTGRES_PASSWORD=postgres" >> venv/Scripts/activate
12 echo "export POSTGRES_DB=postgres" >> venv/Scripts/activate
13 echo "export POSTGRES_HOST=postgres" >> venv/Scripts/activate
14 echo "export POSTGRES_PORT=5821" >> venv/Scripts/activate
15fi
16
17# if first arg is var, add a variable to venv/Scripts/activate
18if [ "$1" = "var" ]; then
19 echo "export $2=$3" >> venv/Scripts/activate
20fi
21
22# if venv is activated, deactivate it
23if [ ! -z "$VIRTUAL_ENV" ]; then
24 deactivate
25fi
26source venv/Scripts/activate
27
28# if first arg is back, build frontend and run backend
29if [ "$1" = "back" ]; then
30 # build the frontend
31 cd rango/frontend
32 npm run build
33 cd ../..
34
35 # compose up the dev compose file
36 docker compose -f dev-compose.yml up -d
37
38 # create secret key if .env doesn't exist
39 cd rango/backend
40 if [ ! -f ".env" ]; then
41 python manage.py createsecret
42 fi
43
44 # migrate database
45 python manage.py migrate
46
47 # run backend development server
48 python manage.py runserver & cd ../..
49fi
50
51# if first arg is front, run frontend development server
52if [ "$1" = "front" ]; then
53 cd rango/frontend
54 npm run dev & cd ../..
55fi