irongit

better dev scripts

FIRST_NAME LAST_NAMEauthored
parent 39a2dddcommit 13e07cceb9a89f3289bc1913f5c1d1b66196a506Browse files

7 files changed, +70 -15

+11-6dev
@@ -1,17 +1,22 @@
11 #!/bin/bash
22 # For development only
33
4-# if venv doesn't exist initialize it
4+# if no venv
55 if [ ! -d "venv" ]; then
6- bash devscripts/init
6+ # if no args or init, run init
7+ if [ -z "$1" ] || [ "$1" = "init" ]; then
8+ bash devscripts/init
9+ exit 0
10+ else
11+ echo "No venv found, run init first"
12+ exit 1
13+ fi
714 fi
8-bash devscripts/activate_ready
9-source venv/**/activate
1015
1116 # run devscript for args 1+ if they exist
1217 if [ -n "$1" ]; then
18+ source venv/**/activate
1319 bash devscripts/$1 ${@:2}
1420 else
15- docker compose down
16- docker compose up --build --remove-orphans
21+ echo "No arguments provided"
1722 fi
+1-8devscripts/back
@@ -1,22 +1,15 @@
11 #!/bin/bash
22
3-# start the development docker container
4-docker compose down
5-docker compose -f dev-compose.yml up -d --remove-orphans
3+bash devscripts/compose
64
7-python -m pip install --upgrade pip
85 cd rango/backend
9-python -m pip install -r requirements.txt
106
11-# if no .env with ls -a in backend, create one
127 if [ ! -f .env ]; then
13- echo "Creating .env file"
148 python manage.py createsecret
159 fi
1610
1711 # if no argument, run the backend
1812 if [ -z "$1" ]; then
19- python manage.py migrate
2013 python manage.py runserver 0.0.0.0:8000
2114 else
2215 # run the arguments as python manage.py
+13-0devscripts/compose
@@ -0,0 +1,13 @@
1+#!/bin/bash
2+
3+# start the development docker container
4+if [ -z "$1" ]; then
5+ docker-compose -f dev-compose.yml up -d --remove-orphans
6+ # while docker compose logs not have "database system is ready to accept connections" sleep 1
7+ while ! docker-compose -f dev-compose.yml logs | grep "database system is ready to accept connections";
8+ do sleep 1
9+ echo "Waiting for database to be ready"
10+ done
11+else
12+ docker-compose -f dev-compose.yml $1 ${@:2}
13+fi
+0-1devscripts/front
@@ -1,7 +1,6 @@
11 #!/bin/bash
22
33 cd rango/frontend
4-npm install
54
65 # if there is no argument, run the npm dev server
76 # else npm run the command
+30-0devscripts/init
@@ -9,3 +9,33 @@ echo "export POSTGRES_PASSWORD=postgres" >> venv/**/activate
99 echo "export POSTGRES_DB=postgres" >> venv/**/activate
1010 echo "export POSTGRES_HOST=localhost" >> venv/**/activate
1111 echo "export POSTGRES_PORT=5821" >> venv/**/activate
12+
13+# Activate the virtual environment until successful and sleep in between tries
14+echo "Activating virtual environment"
15+source venv/**/activate
16+while [ $? -ne 0 ]; do
17+ echo "Failed to activate virtual environment, trying again in 1 second"
18+ source venv/**/activate
19+ sleep 1
20+done
21+
22+# Install the requirements until successful and sleep in between tries
23+cd rango/backend
24+echo "Installing requirements"
25+pip install -r requirements.txt
26+while [ $? -ne 0 ]; do
27+ echo "Failed to install requirements, trying again in 1 second"
28+ pip install -r requirements.txt
29+ sleep 1
30+done
31+
32+# Install the frontend requirements until successful and sleep in between tries
33+cd ../frontend
34+echo "Installing frontend requirements"
35+npm install
36+while [ $? -ne 0 ]; do
37+ echo "Failed to install frontend requirements, trying again in 1 second"
38+ npm install
39+ sleep 1
40+done
41+
+13-0devscripts/vscode
@@ -0,0 +1,13 @@
1+#!/bin/bash
2+
3+# if disable move .vscode to .vscode.template
4+if [ "$1" = "disable" ]; then
5+ mv .vscode .vscode.template
6+ exit 0
7+fi
8+
9+# if enable move .vscode.template to .vscode
10+if [ "$1" = "enable" ]; then
11+ mv .vscode.template .vscode
12+ exit 0
13+fi
+2-0entrypoint.sh
@@ -0,0 +1,2 @@
1+#!/bin/bash
2+docker compose up --build --remove-orphans -d