diff --git a/Dockerfile b/Dockerfile index 3c1742b..52cf033 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,9 @@ WORKDIR /app # Bricktracker COPY . . +# Fix line endings and set executable permissions for entrypoint script +RUN sed -i 's/\r$//' entrypoint.sh && chmod +x entrypoint.sh + # Python library requirements RUN pip --no-cache-dir install -r requirements.txt diff --git a/entrypoint.sh b/entrypoint.sh index 148c366..5570eee 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -13,4 +13,4 @@ then fi # Execute the WSGI server -gunicorn --bind "${BK_SERVER}:${BK_PORT}" "app:create_app()" --worker-class "eventlet" "$@" +gunicorn --bind "${BK_HOST}:${BK_PORT}" "wsgi:application" --worker-class "gevent" --workers 1 "$@" diff --git a/wsgi.py b/wsgi.py new file mode 100644 index 0000000..290f731 --- /dev/null +++ b/wsgi.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +""" +WSGI entry point for BrickTracker - Production Docker deployment +This ensures proper gevent monkey patching for gunicorn +""" + +# CRITICAL: This must be the very first import +import gevent.monkey +gevent.monkey.patch_all() + +import logging +import sys +import os + +# Add the current directory to Python path +sys.path.insert(0, os.path.dirname(__file__)) + +# Import Flask and BrickTracker modules directly +from flask import Flask +from bricktracker.app import setup_app +from bricktracker.socket import BrickSocket + +logger = logging.getLogger(__name__) + +# Create the Flask app directly (bypassing app.py to avoid double monkey patching) +app = Flask(__name__) + +# Setup the app +setup_app(app) + +# Create the socket +socket_instance = BrickSocket( + app, + threaded=not app.config['NO_THREADED_SOCKET'], +) + +# Export the Flask app for gunicorn +application = app \ No newline at end of file