irongit
rango/dev
53 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
39 cd rango/backend
40 python manage.py createsecret
41
42 # migrate database
43 python manage.py migrate
44
45 # run backend development server
46 python manage.py runserver & cd ../..
47fi
48
49# if first arg is front, run frontend development server
50if [ "$1" = "front" ]; then
51 cd rango/frontend
52 npm run dev & cd ../..
53fi