diff --git a/Dockerfile b/Dockerfile index c55f8f3..90251cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN pip install --no-cache-dir -r requirements.txt # The .dockerignore file ensures we only include what's specified COPY musicround/ ./musicround/ COPY migrations/ ./migrations/ -COPY run_migration.py run.py docker-entrypoint.sh LICENSE favicon.ico . +COPY run_migration.py run.py wsgi.py docker-entrypoint.sh LICENSE favicon.ico . # Make the entrypoint script executable RUN chmod +x docker-entrypoint.sh @@ -31,4 +31,4 @@ ENV PYTHONPATH=/app ENV FLASK_APP=run.py # Use the entrypoint script -CMD ["./docker-entrypoint.sh"] \ No newline at end of file +CMD ["./docker-entrypoint.sh"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 815acc3..a11343f 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -23,7 +23,18 @@ case "${FLASK_DEBUG,,}" in exec python -m flask run --host=0.0.0.0 --port=5000 --reload --debug ;; *) - echo "Starting Flask application server..." - exec python run.py + : "${GUNICORN_BIND:=0.0.0.0:5000}" + : "${GUNICORN_WORKERS:=2}" + : "${GUNICORN_THREADS:=4}" + : "${GUNICORN_TIMEOUT:=120}" + echo "Starting Gunicorn application server..." + exec gunicorn \ + --bind "$GUNICORN_BIND" \ + --workers "$GUNICORN_WORKERS" \ + --threads "$GUNICORN_THREADS" \ + --timeout "$GUNICORN_TIMEOUT" \ + --access-logfile - \ + --error-logfile - \ + wsgi:app ;; esac diff --git a/requirements.txt b/requirements.txt index 176b92f..b574beb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,9 +17,10 @@ Flask-Mail Flask-Session authlib>=1.6.5 Flask-Caching +gunicorn psutil # Testing dependencies pytest>=7.4.0 pytest-cov>=4.1.0 -pytest-flask>=1.2.0 \ No newline at end of file +pytest-flask>=1.2.0 diff --git a/wsgi.py b/wsgi.py new file mode 100644 index 0000000..933167d --- /dev/null +++ b/wsgi.py @@ -0,0 +1,3 @@ +from musicround import create_app + +app = create_app()