diff --git a/Dockerfile b/Dockerfile index 063151b..d708d51 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,6 @@ COPY . /protocol-builder-mock/ ENV FLASK_APP=/protocol-builder-mock/app.py # run webserver by default -CMD ["pipenv", "run", "flask", "db", "upgrade"] CMD ["pipenv", "run", "python", "/protocol-builder-mock/run.py"] # expose ports diff --git a/app.py b/app.py index f776df0..85f200c 100644 --- a/app.py +++ b/app.py @@ -107,7 +107,7 @@ def index(): # display results studies = db.session.query(Study).order_by(Study.DATE_MODIFIED.desc()).all() table = StudyTable(studies) - return render_template('index.html', table=table) + return render_template('index.html', table=table, BASE_HREF=app.config['BASE_HREF']) @app.route('/new_study', methods=['GET', 'POST']) diff --git a/config/default.py b/config/default.py index 0d552d9..3b70fbf 100644 --- a/config/default.py +++ b/config/default.py @@ -8,6 +8,7 @@ FLASK_PORT = environ.get('PORT0') or environ.get('FLASK_PORT', default="5001") CORS_ENABLED = False DEVELOPMENT = environ.get('DEVELOPMENT', default="true") == "true" TESTING = environ.get('TESTING', default="false") == "true" +BASE_HREF = environ.get('BASE_HREF', default="/") DB_HOST = environ.get('DB_HOST', default="localhost") DB_PORT = environ.get('DB_PORT', default="5432") diff --git a/docker_run.sh b/docker_run.sh index a24b6db..5886817 100755 --- a/docker_run.sh +++ b/docker_run.sh @@ -2,5 +2,20 @@ # run migrations export FLASK_APP=./app.py -pipenv run flask db upgrade + +if [ "$DOWNGRADE_DB" = "true" ]; then + echo 'Downgrading database...' + pipenv run flask db downgrade +fi + +if [ "$UPGRADE_DB" = "true" ]; then + echo 'Upgrading database...' + pipenv run flask db upgrade +fi + +if [ "$RESET_DB" = "true" ]; then + echo 'Resetting database...' + pipenv run flask load-example-data +fi + pipenv run python ./run.py diff --git a/templates/index.html b/templates/index.html index 273fcd3..cb241c7 100644 --- a/templates/index.html +++ b/templates/index.html @@ -2,6 +2,7 @@