diff --git a/Dockerfile b/Dockerfile index accc30d..7a27f03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,13 +9,10 @@ WORKDIR /app # Install system dependencies # WeasyPrint needs: libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz-subset0 libjpeg-dev libopenjp2-7-dev libxcb1 -# MySQLclient needs: default-libmysqlclient-dev gcc pkg-config -# MariaDB Client is added to ensure all authentication plugins (like mysql_native_password) are available for MariaDB 11 +# PyMySQL does not need libmysqlclient-dev, but we keep basic build tools RUN apt-get update && apt-get install -y \ gcc \ pkg-config \ - default-libmysqlclient-dev \ - mariadb-client \ libpango-1.0-0 \ libpangoft2-1.0-0 \ libharfbuzz-subset0 \ @@ -40,4 +37,4 @@ RUN chmod +x /app/entrypoint.sh EXPOSE 8000 # Entrypoint -ENTRYPOINT ["/app/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/app/entrypoint.sh"] diff --git a/config/__init__.py b/config/__init__.py index e69de29..9c0f756 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -0,0 +1,3 @@ +import pymysql + +pymysql.install_as_MySQLdb() diff --git a/config/wsgi.py b/config/wsgi.py index e2fbd58..05c92fe 100644 --- a/config/wsgi.py +++ b/config/wsgi.py @@ -8,9 +8,12 @@ https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/ """ import os +import pymysql + +pymysql.install_as_MySQLdb() from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings') -application = get_wsgi_application() +application = get_wsgi_application() \ No newline at end of file diff --git a/core/management/commands/wait_for_db.py b/core/management/commands/wait_for_db.py index cee1a06..5543050 100644 --- a/core/management/commands/wait_for_db.py +++ b/core/management/commands/wait_for_db.py @@ -16,6 +16,15 @@ class Command(BaseCommand): db_conf = settings.DATABASES['default'] self.stdout.write(f"Debug Info - Host: {db_conf.get('HOST')}, Port: {db_conf.get('PORT')}, Name: {db_conf.get('NAME')}, User: {db_conf.get('USER')}") + # DEBUG: Check which MySQLdb is loaded + try: + import MySQLdb + self.stdout.write(f"DEBUG: MySQLdb module is: {MySQLdb}") + if hasattr(MySQLdb, '__file__'): + self.stdout.write(f"DEBUG: MySQLdb location: {MySQLdb.__file__}") + except ImportError: + self.stdout.write("DEBUG: MySQLdb module could NOT be imported.") + self.stdout.write('Waiting for database...') db_conn = None for i in range(30): # Retry for 30 seconds @@ -41,4 +50,4 @@ class Command(BaseCommand): self.stdout.write(self.style.WARNING(f'Database error: {e}, waiting 1 second...')) time.sleep(1) - self.stdout.write(self.style.ERROR('Database unavailable after 30 seconds.')) + self.stdout.write(self.style.ERROR('Database unavailable after 30 seconds.')) \ No newline at end of file diff --git a/manage.py b/manage.py index 8e7ac79..ff3cff4 100755 --- a/manage.py +++ b/manage.py @@ -2,6 +2,9 @@ """Django's command-line utility for administrative tasks.""" import os import sys +import pymysql + +pymysql.install_as_MySQLdb() def main(): @@ -19,4 +22,4 @@ def main(): if __name__ == '__main__': - main() + main() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index acabb89..206132a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ Django==5.2.7 -mysqlclient==2.2.7 +pymysql +cryptography python-dotenv==1.1.1 Pillow weasyprint @@ -10,4 +11,4 @@ drf-yasg gunicorn==22.0.0 django-cors-headers django-admin-rangefilter -requests +requests \ No newline at end of file