diff --git a/.env.sample b/.env.sample index cca5ab8..425e309 100644 --- a/.env.sample +++ b/.env.sample @@ -30,5 +30,5 @@ PHP_DATE_TIMEZONE="UTC" SECRET_DB_PASSWORD_VERSION=v1 SECRET_DB_ROOT_PASSWORD_VERSION=v1 SECRET_CIVICRM_SITE_KEY_VERSION=v1 # length=16 -SECRET_CIVICRM_CRED_KEY_VERSION=v1 # length=32 -SECRET_CIVICRM_SIGN_KEY_VERSION=v1 # length=32 \ No newline at end of file +SECRET_CIVICRM_CRED_KEY_VERSION=v1 # length=43 +SECRET_CIVICRM_SIGN_KEY_VERSION=v1 # length=43 \ No newline at end of file diff --git a/civicrm.settings.php b/civicrm.settings.php index ca1abe1..53b282f 100644 --- a/civicrm.settings.php +++ b/civicrm.settings.php @@ -4,17 +4,17 @@ global $civicrm_root, $civicrm_setting, $civicrm_paths; // CMS specific stuff define('CIVICRM_UF', 'WordPress'); $civicrm_root = '/var/www/html/wp-content/plugins/civicrm/civicrm/'; + define('CIVICRM_TEMPLATE_COMPILEDIR', '/var/www/html/wp-content/uploads/civicrm/templates_c/'); -define('CIVICRM_PLUGIN_DIR', '/var/www/html/wp-content/plugins/civicrm/civicrm/'); -define('CIVICRM_PLUGIN_URL', getenv('BASE_URL') . '/wp-content/plugins/civicrm/civicrm/'); // Constants set by env variables define('CIVICRM_DSN', 'mysql://' . getenv('CIVICRM_DB_USER') . ':' . getenv('CIVICRM_DB_PASS') . '@' . getenv('CIVICRM_DB_HOST') . '/' . getenv('CIVICRM_DB_NAME') . '?new_link=true'); define('CIVICRM_UF_DSN', 'mysql://' . getenv('WORDPRESS_DB_USER') . ':' . getenv('WORDPRESS_DB_PASS') . '@' . getenv('WORDPRESS_DB_HOST') . '/' . getenv('WORDPRESS_DB_NAME') . '?new_link=true'); define('CIVICRM_UF_BASEURL', getenv('BASE_URL')); -define('CIVICRM_SITE_KEY', getenv('CIVICRM_SITE_KEY')); -define('CIVICRM_CRED_KEYS', getenv('CIVICRM_CRED_KEYS')); -define('CIVICRM_SIGN_KEYS', getenv('CIVICRM_SIGN_KEYS')); + +define( 'CIVICRM_SITE_KEY', '{{ secret "civicrm_site_key" }}'); +define( 'CIVICRM_SIGN_KEYS', 'jwt-hs256:hkdf-sha256:{{ secret "civicrm_sign_key" }}'); +define( 'CIVICRM_CRED_KEYS', 'aes-cbc:hkdf-sha256:{{ secret "civicrm_cred_key" }}'); // Predefined constants define('CIVICRM_LOGGING_DSN', CIVICRM_DSN); @@ -23,7 +23,14 @@ define('CIVICRM_MAIL_SMARTY', 0); define('CIVICRM_DB_CACHE_CLASS', 'ArrayCache'); define('CIVICRM_PSR16_STRICT', FALSE); define('CIVICRM_DEADLOCK_RETRIES', 3); -define('CIVICRM_EXCLUDE_DIRS_PATTERN', '@/(\.|node_modules|js/|css/|bower_components|packages/|sites/default/files/private)@'); +if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' && !defined('CIVICRM_EXCLUDE_DIRS_PATTERN')) { + define('CIVICRM_EXCLUDE_DIRS_PATTERN', '@/(\.|node_modules|js/|css/|bower_components|packages/|sites/default/files/private)@'); +} + +$civicrm_paths['wp.frontend.base']['url'] = getenv('BASE_URL'); +$civicrm_paths['wp.backend.base']['url'] = getenv('BASE_URL') . '/wp-admin/'; +$civicrm_setting['domain']['userFrameworkResourceURL'] = getenv('BASE_URL') . '/wp-content/plugins/civicrm/civicrm'; + // Include path $include_path = '.' . PATH_SEPARATOR . @@ -35,37 +42,40 @@ if (set_include_path($include_path) === FALSE) { exit(); } -// Clean URLs if (!defined('CIVICRM_CLEANURL')) { - if (function_exists('variable_get') && variable_get('clean_url', '0') != '0') { - define('CIVICRM_CLEANURL', 1); + // check for Drupal clean URLs + if ( function_exists('variable_get') && variable_get('clean_url', '0') != '0') { + define('CIVICRM_CLEANURL', 1 ); } - elseif (function_exists('config_get') && config_get('system.core', 'clean_url') != 0) { - define('CIVICRM_CLEANURL', 1); + elseif ( function_exists('config_get') && config_get('system.core', 'clean_url') != 0) { + define('CIVICRM_CLEANURL', 1 ); } - elseif (function_exists('get_option') && get_option('permalink_structure') != '') { - define('CIVICRM_CLEANURL', 1); + // check for WordPress clean URLs + elseif( function_exists('get_option') && get_option('permalink_structure') != '' ) { + define('CIVICRM_CLEANURL', 1 ); } else { - define('CIVICRM_CLEANURL', 0); + define('CIVICRM_CLEANURL', 0 ); } } -// More stuff that probably shouldn't be in a settings file -ini_set('auto_detect_line_endings', '1'); +// force PHP to auto-detect Mac line endings +if (version_compare(PHP_VERSION, '8.1') < 0) { + ini_set('auto_detect_line_endings', '1'); +} + +// make sure the memory_limit is at least 64 MB $memLimitString = trim(ini_get('memory_limit')); $memLimitUnit = strtolower(substr($memLimitString, -1)); $memLimit = (int) $memLimitString; switch ($memLimitUnit) { - case 'g': - $memLimit *= 1024; - case 'm': - $memLimit *= 1024; - case 'k': - $memLimit *= 1024; + case 'g': $memLimit *= 1024; + case 'm': $memLimit *= 1024; + case 'k': $memLimit *= 1024; } if ($memLimit >= 0 and $memLimit < 134217728) { - ini_set('memory_limit', '128M'); + ini_set('memory_limit', '128M'); } -require_once $civicrm_root . '/CRM/Core/ClassLoader.php'; -CRM_Core_ClassLoader::singleton()->register(); \ No newline at end of file + +require_once 'CRM/Core/ClassLoader.php'; +CRM_Core_ClassLoader::singleton()->register(); diff --git a/compose.yml b/compose.yml index ed6cf78..8f0ffa9 100644 --- a/compose.yml +++ b/compose.yml @@ -3,7 +3,7 @@ version: "3.8" services: app: - image: michaelmcandrew/civicrm:5.56.0-wordpress-php7.4 + image: michaelmcandrew/civicrm:5.59.2-wordpress-php8.1 hostname: civicrm environment: - PROJECT_NAME @@ -20,9 +20,6 @@ services: - WORDPRESS_DB_PORT=3306 - SMTP_HOST - SMTP_MAILDOMAIN - - CIVICRM_SITE_KEY_FILE=/run/secrets/civicrm_site_key - - CIVICRM_CRED_KEYS_FILE=/run/secrets/civicrm_cred_key - - CIVICRM_SIGN_KEYS_FILE=/run/secrets/civicrm_sign_key secrets: - db_password - civicrm_site_key diff --git a/entrypoint.sh b/entrypoint.sh index 7c7005b..b81ef20 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -27,7 +27,6 @@ file_env "WORDPRESS_DB_PASS" file_env "CIVICRM_DB_PASS" file_env "CIVICRM_SITE_KEY" file_env "CIVICRM_CRED_KEYS" -file_env "CIVICRM_SIGN_KEYS" until mysql -e '\q' -h db -p"${WORDPRESS_DB_PASS}" && mysql -e '\q' -h db-civicrm -p"${CIVICRM_DB_PASS}"; do echo "Waiting for db container to come up" @@ -37,8 +36,23 @@ done; echo "=== Running Docker Entrypoint" /usr/local/bin/civicrm-docker-entrypoint +echo "Installing Wordpress" +su civicrm -c "wp core install --locale=de_DE --url=$BASE_URL --title=$PROJECT_NAME --admin_user=admin --admin_email=admin@example.org" + echo "=== Running Civicrm Docker Install" -su civicrm -c /usr/local/bin/civicrm-docker-install +pushd /var/www/html/wp-content/civicrm/ + mv l10n civicrm/ +popd + +rm -rf /var/www/html/wp-content/uploads/civicrm/civicrm.settings.php +su civicrm -c "wp plugin activate civicrm" +su civicrm -c "cv core:install -vv --keep --db=mysql://$CIVICRM_DB_USER:$CIVICRM_DB_PASS@$CIVICRM_DB_HOST:$CIVICRM_DB_PORT/$CIVICRM_DB_NAME --lang de_DE --comp CiviEvent,CiviMember" + +pushd /var/www/html/wp-content/uploads/civicrm + mv civicrm.settings.php civicrm.settings.php.generated + cp /usr/local/etc/civicrm/civicrm.settings.php civicrm.settings.php + chmod a-wx /var/www/html/wp-content/uploads/civicrm/civicrm.settings.php +popd echo "=== Running Apache2" -exec apache2-foreground +exec apache2-foreground \ No newline at end of file