feat: SugarCRM 6.5.26 CE - Docker + compose + CI/CD
Some checks failed
Docker Build & Push SugarCRM 6.5 CE / build-and-push (push) Has been cancelled

- PHP 5.6 Apache Dockerfile (Debian Jessie, archive repos)
- Source from bklein01/sugarcrm GitHub mirror
- MySQL 5.7 database with healthcheck
- Silent install via init.sh (AdminWizard disabled)
- REST v4.1 API test script (test_api.py)
- Gitea Actions CI/CD for registry push
- Full README with API docs and pitfall notes
This commit is contained in:
root
2026-05-24 14:33:08 +02:00
parent 30905b15d4
commit 1c4a366409
14 changed files with 576 additions and 334 deletions

137
init.sh Normal file
View File

@@ -0,0 +1,137 @@
#!/bin/sh
# SugarCRM 6.5 CE Docker Entrypoint
# ==================================
# Pitfalls documented (see README.md Technical Notes)
# Resolve DB connection from env/linked container
if [ -z "$DB_HOST_NAME" ]; then
export DB_HOST_NAME=${DB_PORT_3306_TCP_ADDR:-db}
fi
if [ -z "$DB_TCP_PORT" ]; then
export DB_TCP_PORT=${DB_PORT_3306_TCP_PORT:-3306}
fi
if [ -z "$DB_USER_NAME" ]; then
export DB_USER_NAME=${DB_ENV_MYSQL_USER:-sugarcrm}
fi
if [ -z "$DB_PASSWORD" ]; then
export DB_PASSWORD=${DB_ENV_MYSQL_PASSWORD:-sugarcrm_secret}
fi
if [ -z "$DATABASE_NAME" ]; then
export DATABASE_NAME=${DB_ENV_MYSQL_DATABASE:-sugarcrm}
fi
/usr/local/bin/envtemplate.py -i /usr/local/src/config_override.php.pyt -o /var/www/html/config_override.php
# Start Apache in background for silent install via HTTP
echo "Starting Apache (background)..."
apachectl -DFOREGROUND &
APACHE_PID=$!
# Wait for Apache to be ready
echo "Waiting for Apache..."
for i in $(seq 1 30); do
if curl -s http://localhost/ >/dev/null 2>&1; then
echo "Apache is ready"
break
fi
sleep 1
done
# Run silent install if not already installed
if [ ! -f /var/www/html/config.php ]; then
echo "Running SugarCRM Silent Install..."
cat > /var/www/html/config_si.php << SIEOF
<?php
\$sugar_config_si = array(
'setup_db_host_name' => 'DB_HOST',
'setup_db_database_name' => 'DB_NAME',
'setup_db_admin_user_name' => 'DB_USER',
'setup_db_admin_password' => 'DB_PASS',
'setup_db_type' => 'mysql',
'setup_db_port_num' => 'DB_PORT',
'setup_db_drop_tables' => false,
'setup_db_create_database' => false,
'setup_db_create_sugarsales_user' => false,
'setup_license_key' => 'free',
'setup_license_accept' => true,
'setup_site_url' => 'http://localhost:2080',
'setup_system_name' => 'SugarCRM 6.5 CE',
'setup_site_admin_user_name' => 'admin',
'setup_site_admin_password' => 'admin123',
'setup_site_admin_password_retype' => 'admin123',
'demoData' => 'no',
'dbUSRData' => 'create',
);
SIEOF
sed -i "s/DB_HOST/$DB_HOST_NAME/g" /var/www/html/config_si.php
sed -i "s/DB_NAME/$DATABASE_NAME/g" /var/www/html/config_si.php
sed -i "s/DB_USER/$DB_USER_NAME/g" /var/www/html/config_si.php
sed -i "s/DB_PASS/$DB_PASSWORD/g" /var/www/html/config_si.php
sed -i "s/DB_PORT/$DB_TCP_PORT/g" /var/www/html/config_si.php
# Wait for MySQL (using PHP socket check - no mysqladmin in container)
echo "Waiting for MySQL..."
for i in $(seq 1 30); do
if php -r "\$c=@mysql_connect('$DB_HOST_NAME:$DB_TCP_PORT','$DB_USER_NAME','$DB_PASSWORD');if(\$c){mysql_close(\$c);exit(0);}exit(1);" 2>/dev/null; then
echo "MySQL is ready"
break
fi
sleep 2
done
# Run silent install via HTTP
echo "Executing silent install..."
curl -s "http://localhost/install.php?goto=SilentInstall&cli=true" > /dev/null 2>&1
if [ -f /var/www/html/config.php ]; then
echo "Silent install complete"
# Fix: installer_locked=true to prevent AdminWizard blocking API
sed -i "s/'installer_locked' => false/'installer_locked' => true/" /var/www/html/config.php 2>/dev/null || true
# Skip Admin Wizard in config.php
sed -i "/'site_url' =>/a\\
'adminwizard' => array('completed' => true)," /var/www/html/config.php 2>/dev/null || true
# Skip Admin Wizard in database (pitfall: needed for API access after restart)
php -r "
\$c = @mysql_connect('$DB_HOST_NAME:$DB_TCP_PORT', '$DB_USER_NAME', '$DB_PASSWORD');
if (\$c) {
mysql_select_db('$DATABASE_NAME', \$c);
mysql_query(\"INSERT INTO config (category, name, value) VALUES ('system', 'adminwizard', '{\\\"completed\\\":true}')\", \$c);
mysql_close(\$c);
}
" 2>/dev/null || true
echo "Admin Wizard disabled"
else
echo "WARNING: config.php was not created! Check install."
fi
else
echo "SugarCRM already installed"
# Ensure installer_locked is true (idempotent restart fix)
if grep -q "'installer_locked' => false" /var/www/html/config.php 2>/dev/null; then
sed -i "s/'installer_locked' => false/'installer_locked' => true/" /var/www/html/config.php
echo "Fixed installer_locked"
fi
# Ensure Admin Wizard remains disabled
if ! grep -q adminwizard /var/www/html/config.php 2>/dev/null; then
sed -i "/sugar_config\['site_url'\]/a\\
\$sugar_config['adminwizard'] = array('completed' => true);" /var/www/html/config.php 2>/dev/null || true
echo "Admin Wizard disabled"
fi
fi
# Clean up
rm -f /var/www/html/config_si.php
# Start cron
/usr/sbin/cron
# Bring Apache to foreground
echo "Setup complete. SugarCRM 6.5.26 CE ready."
wait $APACHE_PID