better dev scripts
7 files changed, +70 -15
+11-6dev
| @@ -1,17 +1,22 @@ | ||
| 1 | 1 | #!/bin/bash |
| 2 | 2 | # For development only |
| 3 | 3 | |
| 4 | -# if venv doesn't exist initialize it | |
| 4 | +# if no venv | |
| 5 | 5 | 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 | |
| 7 | 14 | fi |
| 8 | -bash devscripts/activate_ready | |
| 9 | -source venv/**/activate | |
| 10 | 15 | |
| 11 | 16 | # run devscript for args 1+ if they exist |
| 12 | 17 | if [ -n "$1" ]; then |
| 18 | + source venv/**/activate | |
| 13 | 19 | bash devscripts/$1 ${@:2} |
| 14 | 20 | else |
| 15 | - docker compose down | |
| 16 | - docker compose up --build --remove-orphans | |
| 21 | + echo "No arguments provided" | |
| 17 | 22 | fi |
+1-8devscripts/back
| @@ -1,22 +1,15 @@ | ||
| 1 | 1 | #!/bin/bash |
| 2 | 2 | |
| 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 | |
| 6 | 4 | |
| 7 | -python -m pip install --upgrade pip | |
| 8 | 5 | cd rango/backend |
| 9 | -python -m pip install -r requirements.txt | |
| 10 | 6 | |
| 11 | -# if no .env with ls -a in backend, create one | |
| 12 | 7 | if [ ! -f .env ]; then |
| 13 | - echo "Creating .env file" | |
| 14 | 8 | python manage.py createsecret |
| 15 | 9 | fi |
| 16 | 10 | |
| 17 | 11 | # if no argument, run the backend |
| 18 | 12 | if [ -z "$1" ]; then |
| 19 | - python manage.py migrate | |
| 20 | 13 | python manage.py runserver 0.0.0.0:8000 |
| 21 | 14 | else |
| 22 | 15 | # 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 @@ | ||
| 1 | 1 | #!/bin/bash |
| 2 | 2 | |
| 3 | 3 | cd rango/frontend |
| 4 | -npm install | |
| 5 | 4 | |
| 6 | 5 | # if there is no argument, run the npm dev server |
| 7 | 6 | # else npm run the command |
+30-0devscripts/init
| @@ -9,3 +9,33 @@ echo "export POSTGRES_PASSWORD=postgres" >> venv/**/activate | ||
| 9 | 9 | echo "export POSTGRES_DB=postgres" >> venv/**/activate |
| 10 | 10 | echo "export POSTGRES_HOST=localhost" >> venv/**/activate |
| 11 | 11 | 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 |