fix: replace mysqladmin with PHP mysqlnd for MySQL 8 compatibility

The MariaDB CLI client (default-mysql-client on Debian) cannot complete
the caching_sha2_password handshake used by MySQL 8.0, so the entrypoint
wait loop never exited.

- Dockerfile: remove default-mysql-client (no longer needed)
- docker-entrypoint.sh: wait loop now uses a PHP one-liner via mysqli_connect
  (same mysqlnd driver the app uses — if it connects, the app will too)
- docker-compose.yml: health check pings via local socket without credentials
  (mysqladmin ping -h localhost --silent works inside the DB container)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-11 10:59:39 +02:00
parent 7d401b1963
commit a9d550ba1d
3 changed files with 3 additions and 4 deletions

View File

@@ -35,7 +35,7 @@ services:
# MySQL 8 defaults to caching_sha2_password; keep native auth for broad client compat # MySQL 8 defaults to caching_sha2_password; keep native auth for broad client compat
command: --default-authentication-plugin=mysql_native_password command: --default-authentication-plugin=mysql_native_password
healthcheck: healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "videodb", "-pvideodb_secret"] test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "--silent"]
interval: 10s interval: 10s
timeout: 5s timeout: 5s
retries: 12 retries: 12

View File

@@ -6,7 +6,6 @@ RUN apt-get update && apt-get install -y \
libjpeg-dev \ libjpeg-dev \
libfreetype6-dev \ libfreetype6-dev \
libonig-dev \ libonig-dev \
default-mysql-client \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Install PHP extensions needed by videoDB # Install PHP extensions needed by videoDB

View File

@@ -62,9 +62,9 @@ PHP
chown www-data:www-data "$CONFIG_FILE" chown www-data:www-data "$CONFIG_FILE"
echo "[entrypoint] config.inc.php written." echo "[entrypoint] config.inc.php written."
# ── Wait for MySQL ───────────────────────────────────────────────────────────── # ── Wait for MySQL (use PHP mysqlnd — same driver the app uses) ────────────────
echo "[entrypoint] Waiting for MySQL at ${DB_HOST}..." echo "[entrypoint] Waiting for MySQL at ${DB_HOST}..."
until mysqladmin ping -h "$DB_HOST" -u "$DB_USER" -p"$DB_PASSWORD" --silent 2>/dev/null; do until php -r "exit(@mysqli_connect('${DB_HOST}','${DB_USER}','${DB_PASSWORD}','${DB_NAME}') ? 0 : 1);" 2>/dev/null; do
printf "." printf "."
sleep 2 sleep 2
done done