|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# check to see if a .env file exists |
| 4 | +if [ -f .env ]; then |
| 5 | + echo ".env file exists, loading environment variables from .env file" |
| 6 | +else |
| 7 | + echo ".env file does not exist, copying example.env to .env" |
| 8 | + cp example.env .env |
| 9 | +fi |
| 10 | + |
| 11 | +# load the environment variables from the .env file |
| 12 | +source .env |
| 13 | + |
| 14 | +echo "Setting Environment Variables from .env file:" |
| 15 | +# display the environment variables read in from .env, could be a gotcha if |
| 16 | +# the user is unclear about if the .env variables are being used. The .env variables |
| 17 | +# will override environment variables set in the shell as they're set once this script |
| 18 | +# is run. |
| 19 | +while read line |
| 20 | +do |
| 21 | + # if line does not start with # then echo the line |
| 22 | + if [[ $line != \#* ]]; then |
| 23 | + if [[ $line != "" ]]; then |
| 24 | + echo " ${line}" |
| 25 | + fi |
| 26 | + fi |
| 27 | +done < .env |
| 28 | + |
| 29 | +if [ $BRAINLIFE_DEVELOPMENT == true ]; then |
| 30 | + # enable or disable debugging output |
| 31 | + set -ex |
| 32 | +else |
| 33 | + set -e |
| 34 | +fi |
| 35 | + |
| 36 | +# build local changes and mount them directly into the containers |
| 37 | +# api/ and ui/ are mounted as volumes at /app within the docker-compose.yml |
| 38 | +(cd api && npm install) |
| 39 | +(cd ui && npm install) |
| 40 | + |
| 41 | +# update the bids submodule |
| 42 | +git submodule update --init --recursive |
| 43 | + |
| 44 | +# The main differences between the production and development docker-compose files are that the production |
| 45 | +# files uses https via nginx and the development file uses http. |
| 46 | +if [[ $BRAINLIFE_PRODUCTION == true ]]; then |
| 47 | + DOCKER_COMPOSE_FILE=docker-compose-production.yml |
| 48 | +else |
| 49 | + DOCKER_COMPOSE_FILE=docker-compose.yml |
| 50 | +fi |
| 51 | + |
| 52 | +mkdir -p /tmp/upload |
| 53 | +mkdir -p /tmp/workdir |
| 54 | + |
| 55 | +#npm run prepare-husky |
| 56 | + |
| 57 | +./generate_keys.sh |
| 58 | + |
| 59 | +# ok docker compose is now included in docker as an option for docker |
| 60 | +if [[ $(command -v docker-compose) ]]; then |
| 61 | + # if the older version is installed use the dash |
| 62 | + docker-compose --file ${DOCKER_COMPOSE_FILE} up |
| 63 | +else |
| 64 | + # if the newer version is installed don't use the dash |
| 65 | + docker compose --file ${DOCKER_COMPOSE_FILE} up |
| 66 | +fi |
0 commit comments