From d450994857513cb7dcda4049770743fd4571d256 Mon Sep 17 00:00:00 2001 From: Kobe Date: Thu, 22 May 2025 20:39:04 +0200 Subject: [PATCH] lol --- Dockerfile | 8 ++++++-- init_db.py | 12 ++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 init_db.py diff --git a/Dockerfile b/Dockerfile index 3b63a71..efda033 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,5 +24,9 @@ EXPOSE 5000 ENV FLASK_APP=app.py ENV FLASK_ENV=production -# Run the application with gunicorn -CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--chdir", "/app", "app:app"] \ No newline at end of file +# Create a startup script +RUN echo '#!/bin/bash\npython init_db.py\ngunicorn --bind 0.0.0.0:5000 --chdir /app app:app' > /app/start.sh +RUN chmod +x /app/start.sh + +# Run the startup script +CMD ["/app/start.sh"] \ No newline at end of file diff --git a/init_db.py b/init_db.py new file mode 100644 index 0000000..336c7e8 --- /dev/null +++ b/init_db.py @@ -0,0 +1,12 @@ +from app import app, db +from flask_migrate import upgrade + +def init_db(): + with app.app_context(): + # Create all tables + db.create_all() + # Run any pending migrations + upgrade() + +if __name__ == '__main__': + init_db() \ No newline at end of file