forked from redhat-beyond/tutor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·47 lines (36 loc) · 1.01 KB
/
bootstrap.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
echo "installing python and postgres"
apt update
apt install -y python3.7 python3-pip python3.7-dev postgresql postgresql-contrib postgresql-common postgresql-client libpq-dev
echo "installing dependencies"
pip3 install pipenv
# Not needed on CI
if [ ! "$CI" ]
then
export PIPENV_VENV_IN_PROJECT="enabled"
export VIRTUALENV_ALWAYS_COPY=1
cd /vagrant
fi
pipenv sync --dev
# Need to start postgres service on CI
if [ "$CI" ]
then
sudo systemctl start postgresql
fi
echo "initializing new DB"
sudo -u postgres createdb tutor
sudo -u postgres psql -c "ALTER ROLE postgres WITH PASSWORD 'tutor';"
echo "configure flask variables"
export FLASK_APP=/vagrant/run.py
export FLASK_ENV=development
echo "initializing DB and migrations"
pipenv run python3 run.py db init
pipenv run python3 run.py db migrate
pipenv run python3 run.py db upgrade
# No need to run the app on CI
if [ ! "$CI" ]
then
echo "run tutor app"
pipenv run python3 launch_data.py
nohup pipenv run flask run -h 0.0.0.0 -p 5000
fi