Fix: Force PyMySQL usage to resolve Coolify deployment error (2059)
This commit is contained in:
parent
279c717fdd
commit
7b86c4d661
@ -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"]
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
import pymysql
|
||||
|
||||
pymysql.install_as_MySQLdb()
|
||||
@ -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()
|
||||
@ -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.'))
|
||||
@ -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()
|
||||
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user