Skip to content
Snippets Groups Projects
Commit 88ab22c5 authored by David Trattnig's avatar David Trattnig
Browse files

Initial commit of run scripts.

parent 142faea3
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
BASE_D=$(realpath "${BASH_SOURCE%/*}/")
# Default mode
mode="dev"
docker="false"
exec sudo docker run --rm -it -u $UID:$GID -p 127.0.0.1:8000:8000 -v "$BASE_D":/srv aura/pv /srv/manage.py runserver 0.0.0.0:8000
#
# Run Script for AURA Steering
#
# Call with one of these parameters:
#
# - init
# - dev
# - prod
# - test
# - docker:build
# - docker:push
# - docker:serve
#
if [[ $* =~ ^(init|dev|prod|test|build|push|serve)$ ]]; then
mode=$1
fi
if [[ "$1" == *"docker:"* ]]; then
docker="true"
mode=${1#*:}
fi
echo "[ Run mode=$mode ]"
echo "[ Docker=$docker ]"
# +++ DEFAULT COMMANDS +++ #
if [[ $docker == "false" ]]; then
### Initializes the project (Development) ###
if [[ $mode == "init" ]]; then
echo "Creating Python VirtualEnvironment"
virtualenv -p python3.6 python
echo "Install dependencies"
pip3 install -r requirements.txt
echo "Next you need to create the configuration, run fixtues, migrations and create a superuser."
fi
### Runs the project in development mode (Virtualenv) ###
if [[ $mode == "dev" ]]; then
echo "Activating Python Environment"
source python/bin/activate
python manage.py runserver
fi
### Runs the project in production mode (Production) ###
if [[ $mode == "prod" ]]; then
echo "!!! Not yet implemented !!!"
#gunicorn -c config/gunicorn.conf.py src.app:app
fi
### Runs the test-cases ###
if [[ $mode == "test" ]]; then
echo "!!! Not yet implemented !!!"
fi
fi
# +++ DOCKER COMMANDS +++ #
if [[ $docker == "true" ]]; then
BASE_D=$(realpath "${BASH_SOURCE%/*}/")
### Runs Engine API using Gunicorn ###
if [[ $mode == "serve" ]]; then
exec sudo docker run --rm -it \
-u $UID:$GID \
-p 127.0.0.1:8000:8000 \
-v "$BASE_D":/srv autoradio/steering /srv/manage.py \
runserver 0.0.0.0:8000
fi
### Create Docker Image from local project ###
if [[ $mode == "build" ]]; then
exec sudo docker build -t autoradio/steering .
fi
### Pushes the latest Docker Image to Docker Hub ###
if [[ $mode == "push" ]]; then
exec sudo docker push autoradio/steering
fi
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment