fix: improve database connection handling in entrypoint
Browse files- Add timeout-based PostgreSQL connection check
- Implement max retry attempts (30 attempts, 5s between each)
- Add detailed connection attempt logging
- Maintain compatibility with existing Redis checks
- Exit gracefully if database connection fails after max attempts
References:
docker/entrypoint.sh (lines 1-33)
docker/docker-compose.yaml (lines 331-346)
187 unmodified lines188189190191192193194195196197198199200201202203204205206207208209210211212213187 unmodified linesENV FLASK_APP=app.py \EDITION=SELF_HOSTED \DEPLOY_ENV=PRODUCTION \CONSOLE_API_URL=http://127.0.0.1:7860 \CONSOLE_WEB_URL=http://127.0.0.1:3000 \SERVICE_API_URL=http://127.0.0.1:7860 \APP_WEB_URL=http://127.0.0.1:3000 \PYTHONPATH=/app/api \PATH="/usr/local/bin:${PATH}" \STORAGE_DIR=/storage \# Database configurationDB_USERNAME=${DB_USERNAME:-postgres} \DB_PASSWORD=${DB_PASSWORD:-difyai123456} \DB_HOST=${DB_HOST:-db} \DB_PORT=${DB_PORT:-5432} \DB_DATABASE=${DB_DATABASE:-dify} \SQLALCHEMY_POOL_SIZE=${SQLALCHEMY_POOL_SIZE:-30} \SQLALCHEMY_POOL_RECYCLE=${SQLALCHEMY_POOL_RECYCLE:-3600} \# Redis configurationREDIS_HOST=${REDIS_HOST:-redis} \REDIS_PORT=${REDIS_PORT:-6379} \REDIS_PASSWORD=${REDIS_PASSWORD:-difyai123456} \REDIS_DB=${REDIS_DB:-0}# Copy entrypoint scriptCOPY docker/entrypoint.sh /app/entrypoint.sh187 unmodified lines188189190191192193194195196197198199200201202203204205206207208209187 unmodified linesENV FLASK_APP=app.py \EDITION=SELF_HOSTED \DEPLOY_ENV=PRODUCTION \PYTHONPATH=/app/api \PATH="/usr/local/bin:${PATH}" \STORAGE_DIR=/storage \# Database configuration - match docker-compose.yamlDB_USERNAME=postgres \DB_PASSWORD=difyai123456 \DB_HOST=db \DB_PORT=5432 \DB_DATABASE=dify \SQLALCHEMY_POOL_SIZE=30 \SQLALCHEMY_POOL_RECYCLE=3600 \# Redis configuration - match docker-compose.yamlREDIS_HOST=redis \REDIS_PORT=6379 \REDIS_PASSWORD=difyai123456 \REDIS_DB=0# Copy entrypoint scriptCOPY docker/entrypoint.sh /app/entrypoint.sh
Dockerfile+13-17