Browse Source

docker works without pre-existing instance dir

master
junikimm717 2 years ago
parent
commit
17c3cf32ce
  1. 2
      Dockerfile
  2. 5
      app.py
  3. 4
      docker-compose.yml
  4. 4
      entrypoint.sh
  5. 6
      initialize_db.py
  6. 3
      templates/search.html

2
Dockerfile

@ -14,4 +14,4 @@ RUN poetry install --no-dev
# now copy over everything # now copy over everything
COPY . /app/ COPY . /app/
ENTRYPOINT ["gunicorn", "-b", "0.0.0.0:5000", "app:app"]
ENTRYPOINT ["/app/entrypoint.sh"]

5
app.py

@ -14,8 +14,7 @@ app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///project.db"
app.secret_key = '98d31240f9fbe14c8083586db49c19c3a8d3f726' app.secret_key = '98d31240f9fbe14c8083586db49c19c3a8d3f726'
db.init_app(app) db.init_app(app)
with app.app_context():
db.create_all()
BaseModelForm = model_form_factory(FlaskForm) BaseModelForm = model_form_factory(FlaskForm)
@ -267,4 +266,6 @@ def search():
if __name__ == "__main__": if __name__ == "__main__":
with app.app_context():
db.create_all()
app.run(debug=True) app.run(debug=True)

4
docker-compose.yml

@ -1,8 +1,8 @@
version: '3.9'
version: '2'
services: services:
web: web:
ports: ports:
- "5002:5000" - "5002:5000"
build: . build: .
volumes: volumes:
- ./instance:/app/instance/
- ./instance:/app/instance

4
entrypoint.sh

@ -0,0 +1,4 @@
#!/bin/sh
./initialize_db.py
gunicorn -b 0.0.0.0:5000 app:app

6
initialize_db.py

@ -0,0 +1,6 @@
#!/usr/bin/env python3
from app import db, app
with app.app_context():
db.create_all()

3
templates/search.html

@ -49,8 +49,7 @@
console.error(e); console.error(e);
this.error = true; this.error = true;
}) })
},
//debounced_fetch: debounce(this.fetch_data.bind(this), 300)
}
}, },
created() { created() {
this.fetch_data = debounce(this.fetch_data, 300) this.fetch_data = debounce(this.fetch_data, 300)

Loading…
Cancel
Save