DEV mode: fix MariaDB/memcached install on AlmaLinux 10 and fail visibly
microdnf install MariaDB-server MariaDB-client memcached died in depsolve (MariaDB-client obsoletes the image's AppStream mariadb; mariadb-client-utils requires it), after which the entrypoint carried on: no mysqld, a mysql_creds file for a database that did not exist, and a container that reported healthy. Now (scripts/dev-mode.sh, used by cac and cac-fpm): - dnf install --allowerasing MariaDB-server MariaDB-client from mariadb.org 11.4, falling back to AlmaLinux mariadb-server; memcached from AppStream; --setopt=skip_if_unavailable so one dead repo does not block the rest; install skipped when already present (docker start) - initialise/chown the data dir, start mysqld, wait for mysqladmin ping (60 s) instead of sleep 10 - any failure is logged loudly (FATAL banner) and the entrypoint exits non-zero. The HEALTHCHECK only probes Apache, so 'unhealthy' could not express this; a non-zero exit is unmistakable in docker ps/logs. PROD never runs this code. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
This commit is contained in:
1 parent
7d6a007ef9
commit
0eea05815a
4 files changed
+105
-57
No files matched your search
+4
-28
@@ -69,34 +69,10 @@ open_dir_traversal
|
||||
if [[ $environment == 'DEV' ]]; then
|
||||
echo "Starting Dev Deployment"
|
||||
user_mkdir /home/$user/_db_backups
|
||||
# Ensure microdnf is available for installing MariaDB and memcached in DEV mode
|
||||
if ! command -v microdnf &> /dev/null; then
|
||||
echo "microdnf not found, installing with dnf..."
|
||||
dnf install -y microdnf && dnf clean all
|
||||
fi
|
||||
microdnf install -y MariaDB-server MariaDB-client memcached
|
||||
sed -r -i 's/session.save_path="memcache:11211/session.save_path="localhost:11211/' /etc/php.ini
|
||||
nohup mysqld -umysql &
|
||||
if [ ! -f /home/$user/mysql_creds ]; then
|
||||
echo "Give MySQL a chance to finish starting..."
|
||||
sleep 10
|
||||
mysql_user=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13 ; echo '')
|
||||
mysql_password=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 18 ; echo '')
|
||||
mysql_db=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 6 ; echo '')
|
||||
mysql -e "CREATE DATABASE devdb_"$mysql_db";"
|
||||
mysql -e "CREATE USER '"$mysql_user"'@'localhost' IDENTIFIED BY '"$mysql_password"';"
|
||||
mysql -e "GRANT ALL PRIVILEGES ON *.* TO '"$mysql_user"'@'localhost' WITH GRANT OPTION;"
|
||||
mysql -e "FLUSH PRIVILEGES;"
|
||||
# Create user crontab with MySQL backup job. Written AS THE CUSTOMER
|
||||
# (as_user tee), never by root through a customer path.
|
||||
drop_symlink /home/$user/crontab
|
||||
printf '%s\n' "# User crontab for $user" "*/15 * * * * /scripts/mysql-backup.sh $user devdb_$mysql_db" \
|
||||
| as_user tee /home/$user/crontab >/dev/null
|
||||
printf '%s\n' "MySQL User: $mysql_user" "MySQL Password: $mysql_password" "MySQL Database: devdb_$mysql_db" \
|
||||
| as_user tee /home/$user/mysql_creds
|
||||
|
||||
fi
|
||||
/usr/bin/memcached -d -u $user
|
||||
dev_install_db_and_cache "$user"
|
||||
# A DEV container that could not set up its database/cache/debugger must not
|
||||
# look healthy (HEALTHCHECK only probes Apache): log loudly and exit non-zero.
|
||||
dev_report_failures
|
||||
|
||||
fi
|
||||
|
||||
|
||||
Reference in new issue
Block a user