Commit 6c523dfb authored by jackie / Andrea Ida Malkah Klaura's avatar jackie / Andrea Ida Malkah Klaura
Browse files

fix typo in tank config setup; add dashboard initialisation

parent 96b61f26
......@@ -3,13 +3,20 @@
This is a work in progress repository aimed to create an easy initial setup for the AuRa web components.
When everything is working smooth, it should be integrated into the meta repo.
## TODOs:
* create aura-config.sample.yaml and remove aura-config.yaml and put it into .gitignore
* create options for run.sh
* create setting to switch between prod and dev setups
## To discuss:
* should we fully build the dashboard before starting the webserver?
- atm. the webserver already starts while dashboard is building. a fast user
might visit the frontend with an old build and get an OIDC error, because in
the original build there was another OIDC client ID
### Common pitfalls to elaborate
* Write permission of the container-data/* directories, if they are not created by the containers themselves
......
......@@ -25,6 +25,8 @@ aura:
db_user: tank
db_name: tank
dashboard:
# Number of seconds before token gets invalid, when renewal should be started
VUE_APP_API_STEERING_OIDC_EXPIRE_NOTIFICATION: 120
# How many timeslots should be shown by default? (has to be a string)
VUE_APP_TIMESLOT_FILTER_DEFAULT_NUMSLOTS: 10
# After how many shows to switch to the compact show selector vs the dropdown
......
......@@ -80,6 +80,8 @@ services:
- steering-django
volumes:
- ./dashboard/dist_docker:/aura/dist_docker
- ./dashboard/.env.production:/aura/.env.production
- ./dashboard/.env.development:/aura/.env.development
command: sh build_for_docker.sh
aura-web:
......
......@@ -19,6 +19,42 @@ set_config_steering () {
fi
}
# get_config_dashboard $1 [$2]
# outputs the value of a key, if set in .env.production
# if the parameter $2 is used and set to "dev" the .env.development file will be used
get_config_dashboard () {
if [ "$2" = "dev" ]; then
DASHBOARD_ENV="development"
else
DASHBOARD_ENV="production"
fi
grep -oP "^$1 = ?\K.*$" dashboard/.env.$DASHBOARD_ENV
}
# set_config_dashboard $1 $2 [$3]
# checks the dashboard/.env.production file and updates the key $1 to value $2
# keys are only considered if the are found on the beginning of a line
# if the key does not exist, a new line will be added, otherwise
# the existing line will be overwritten
# if the optional parameter $3 is used and set to "dev" the operations will be
# performed on the dashboard/.env.development file
set_config_dashboard () {
if [ "$3" = "dev" ]; then
DASHBOARD_ENV="development"
else
DASHBOARD_ENV="production"
fi
SETTING_FOUND="false"
grep -q "$1" dashboard/.env.$DASHBOARD_ENV
if [ $? -eq 0 ]; then SETTING_FOUND="true"; fi
if [ -z "$(get_config_dashboard "$1" "$3")" -a $SETTING_FOUND = "false" ]; then
echo "$1 = $2" >> dashboard/.env.$DASHBOARD_ENV
else
VALUE="$2"
sed -i "s/^$1 =.*$/$1 = ${VALUE//\//\\/}/" dashboard/.env.$DASHBOARD_ENV
fi
}
# init_common
# sources .env variables and initialises variables from aura-config.yaml
# and also write the global .env file for docker-compose
......@@ -37,7 +73,12 @@ init_common () {
echo "Reading tank database config from aura-config.yaml"
TANK_DB_PASS="$(docker run --rm -v "${PWD}"/aura-config.yaml:/workdir/aura-config.yaml mikefarah/yq eval '.aura.tank.db_pass' aura-config.yaml)"
TANK_DB_USER="$(docker run --rm -v "${PWD}"/aura-config.yaml:/workdir/aura-config.yaml mikefarah/yq eval '.aura.tank.db_user' aura-config.yaml)"
TANK_DB_NAME="$(docker run --rm -v "${PWD}"/aura-config.yaml:/workdir/aura-config.yaml mikefarah/yq eval '.aura.tanke.db_name' aura-config.yaml)"
TANK_DB_NAME="$(docker run --rm -v "${PWD}"/aura-config.yaml:/workdir/aura-config.yaml mikefarah/yq eval '.aura.tank.db_name' aura-config.yaml)"
echo "Reading dashboard config from aura-config.yaml"
VUE_APP_API_STEERING_OIDC_EXPIRE_NOTIFICATION="$(docker run --rm -v "${PWD}"/aura-config.yaml:/workdir/aura-config.yaml mikefarah/yq eval '.aura.dashboard.VUE_APP_API_STEERING_OIDC_EXPIRE_NOTIFICATION' aura-config.yaml)"
VUE_APP_TIMESLOT_FILTER_DEFAULT_NUMSLOTS="$(docker run --rm -v "${PWD}"/aura-config.yaml:/workdir/aura-config.yaml mikefarah/yq eval '.aura.dashboard.VUE_APP_TIMESLOT_FILTER_DEFAULT_NUMSLOTS' aura-config.yaml)"
VUE_APP_SHOW_THRESHOLD="$(docker run --rm -v "${PWD}"/aura-config.yaml:/workdir/aura-config.yaml mikefarah/yq eval '.aura.dashboard.VUE_APP_SHOW_THRESHOLD' aura-config.yaml)"
VUE_APP_TIMESLOT_FILTER_DEFAULT_DAYS="$(docker run --rm -v "${PWD}"/aura-config.yaml:/workdir/aura-config.yaml mikefarah/yq eval '.aura.dashboard.VUE_APP_TIMESLOT_FILTER_DEFAULT_DAYS' aura-config.yaml)"
echo "Writing global .env for docker-compose"
echo "
STEERING_DB_PASS=$STEERING_DB_PASS
......@@ -76,6 +117,7 @@ init_steering () {
docker exec steering-django python manage.py migrate
echo "Loading fixtures"
docker exec steering-django sh -c 'python manage.py loaddata fixtures/*/*.json'
# TODO: only create user if not already set (or if explicitly demanded)
echo "Creating steering-django superuser account for $USERNAME <$USERMAIL>."
echo "Please provide a (strong) password."
docker exec -it steering-django python manage.py createsuperuser --username "$USERNAME" --email "$USERMAIL"
......@@ -101,10 +143,24 @@ init_tank () {
}
init_dashboard () {
echo "todo: set .env.production variables according to aura config and oidc client"
# we only use the dashboard image to build the static code
# which will be used by the web server to serve under /
docker-compose run --rm dashboard
cp dashboard/sample.env.production dashboard/.env.production
# TODO: set .env.production variables according to aura config and oidc client"
echo "Setting dashboard config values"
set_config_dashboard VUE_APP_BASEURI_STEERING "$HTTP_SCHEMA://$AURA_DOMAIN"
set_config_dashboard VUE_APP_BASEURI_MEDIA "$HTTP_SCHEMA://$AURA_DOMAIN/steering/site_media"
set_config_dashboard VUE_APP_API_STEERING "$HTTP_SCHEMA://$AURA_DOMAIN/steering/api/v1/"
set_config_dashboard VUE_APP_API_STEERING_SHOWS "$HTTP_SCHEMA://$AURA_DOMAIN/steering/api/v1/shows/"
set_config_dashboard VUE_APP_API_TANK "$HTTP_SCHEMA://$AURA_DOMAIN/tank/api/v1/"
set_config_dashboard VUE_APP_TANK "$HTTP_SCHEMA://$AURA_DOMAIN/tank/"
set_config_dashboard VUE_APP_OIDC_CLIENT_ID "$DASHBOARD_CLIENT_ID"
set_config_dashboard VUE_APP_API_STEERING_OIDC_URI "$HTTP_SCHEMA://$AURA_DOMAIN/openid"
set_config_dashboard VUE_APP_API_STEERING_OIDC_EXPIRE_NOTIFICATION "$VUE_APP_API_STEERING_OIDC_EXPIRE_NOTIFICATION"
set_config_dashboard VUE_APP_API_STEERING_OIDC_REDIRECT_URI "$HTTP_SCHEMA://$AURA_DOMAIN/oidc_callback.html"
set_config_dashboard VUE_APP_API_STEERING_OIDC_REDIRECT_URI_SILENT "$HTTP_SCHEMA://$AURA_DOMAIN/oidc_callback_silentRenew.html"
set_config_dashboard VUE_APP_API_STEERING_OIDC_REDIRECT_URI_POSTLOGOUT "$HTTP_SCHEMA://$AURA_DOMAIN"
set_config_dashboard VUE_APP_TIMESLOT_FILTER_DEFAULT_NUMSLOTS "$VUE_APP_TIMESLOT_FILTER_DEFAULT_NUMSLOTS"
set_config_dashboard VUE_APP_SHOW_THRESHOLD "$VUE_APP_SHOW_THRESHOLD"
set_config_dashboard VUE_APP_TIMESLOT_FILTER_DEFAULT_DAYS "$VUE_APP_TIMESLOT_FILTER_DEFAULT_DAYS"
}
init_webserver () {
......@@ -112,10 +168,12 @@ init_webserver () {
}
start_containers () {
echo "Starting steering and tank containers, building dashboard production build"
docker-compose up -d steering tank dashboard
}
start_webserver () {
echo "Start nginx container as web proxy"
docker-compose up -d aura-web
# TODO: implement letsencrypt for prod setup
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment