diff --git a/Dockerfile b/Dockerfile index af2f33d..3d4d615 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM python:3.10-alpine ADD app.py / +ADD wsgi.py / ADD requirements.txt / ADD ./templates /templates/ ADD ./tests tests/ @@ -9,4 +10,4 @@ RUN pip install --upgrade pip RUN pip install -r requirements.txt EXPOSE 8080 -CMD [ "python", "./app.py" ] +CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--access-logfile", "-", "--workers", "3", "wsgi:app"] diff --git a/app.py b/app.py index df6aca5..a10713a 100644 --- a/app.py +++ b/app.py @@ -59,9 +59,5 @@ def update(_id): if __name__ == "__main__": - import logging - from waitress import serve - logging.getLogger('waitress').setLevel(logging.INFO) - logging.getLogger('werkzeug').setLevel(logging.INFO) table = mongo.db.flask_crud - serve(app, host='0.0.0.0', port=8080) + app.run(host="127.0.0.1", port=8080) diff --git a/requirements.txt b/requirements.txt index 1e2064d..f1cd95a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ flask==2.3.2 flask-sqlalchemy==3.0.3 flask-pymongo==2.3.0 -waitress==2.1.2 +gunicorn==22.0.0 flake8 pytest diff --git a/wsgi.py b/wsgi.py new file mode 100644 index 0000000..24b05e2 --- /dev/null +++ b/wsgi.py @@ -0,0 +1,6 @@ +from app import app, mongo + +table = mongo.db.flask_crud + +if __name__ == "__main__": + app.run()