diff --git a/Dockerfile b/Dockerfile index a59a067..2f98dde 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,4 +14,4 @@ RUN poetry install --no-dev # now copy over everything COPY . /app/ -ENTRYPOINT ["gunicorn", "-b", "0.0.0.0:5000", "app:app"] \ No newline at end of file +ENTRYPOINT ["/app/entrypoint.sh"] \ No newline at end of file diff --git a/app.py b/app.py index 5fc0bcb..b6bb840 100755 --- a/app.py +++ b/app.py @@ -14,8 +14,7 @@ app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///project.db" app.secret_key = '98d31240f9fbe14c8083586db49c19c3a8d3f726' db.init_app(app) -with app.app_context(): - db.create_all() + BaseModelForm = model_form_factory(FlaskForm) @@ -267,4 +266,6 @@ def search(): if __name__ == "__main__": + with app.app_context(): + db.create_all() app.run(debug=True) diff --git a/docker-compose.yml b/docker-compose.yml index 2ae241d..931af53 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,8 @@ -version: '3.9' +version: '2' services: web: ports: - "5002:5000" build: . volumes: - - ./instance:/app/instance/ \ No newline at end of file + - ./instance:/app/instance \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..c96bb95 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +./initialize_db.py +gunicorn -b 0.0.0.0:5000 app:app \ No newline at end of file diff --git a/initialize_db.py b/initialize_db.py new file mode 100755 index 0000000..9f7e310 --- /dev/null +++ b/initialize_db.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +from app import db, app + +with app.app_context(): + db.create_all() diff --git a/templates/search.html b/templates/search.html index 17355cf..007a794 100644 --- a/templates/search.html +++ b/templates/search.html @@ -49,8 +49,7 @@ console.error(e); this.error = true; }) - }, - //debounced_fetch: debounce(this.fetch_data.bind(this), 300) + } }, created() { this.fetch_data = debounce(this.fetch_data, 300)