diff --git a/Dockerfile b/Dockerfile index 74c7c47..105593e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,6 +11,7 @@ ENV FLASK_SECRET=production-secret-change-me RUN apt-get update && apt-get install -y \ gcc \ default-libmysqlclient-dev \ + default-mysql-client \ pkg-config \ curl \ && rm -rf /var/lib/apt/lists/* diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index d47708e..3a7ada3 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -7,12 +7,25 @@ echo "🚀 Starting Jobs App container..." # Wait for MySQL to be ready echo "⏳ Waiting for MySQL to be ready..." -while ! mysqladmin ping -h mysql -u jobs -pjobdb --silent; do - echo "MySQL is not ready, waiting..." - sleep 2 -done - -echo "✅ MySQL is ready!" +python -c " +import time +import pymysql +while True: + try: + conn = pymysql.connect( + host='mysql', + user='jobs', + password='jobdb', + database='jobs', + connect_timeout=5 + ) + conn.close() + print('✅ MySQL is ready!') + break + except pymysql.Error as e: + print(f'MySQL is not ready: {e}, waiting...') + time.sleep(2) +" # Run database setup echo "🗄️ Setting up database..."