Added function for template prepare

This commit is contained in:
CHIEFSOFT\ameye
2025-09-15 14:02:24 -04:00
parent fbb3dc6a67
commit 0a14a6315b
+22
View File
@@ -214,6 +214,28 @@ class Provision extends BaseController
return 0;
}
private function prepareTemplateFile($composer_template_contents, $ContainerName, $allocatedPort, $provisionUID): string
{
$SITE_CONTENTS_GATEWAY = $_ENV['SITE_CONTENTS_GATEWAY'];
$SITE_CONTACT_GATEWAY = $_ENV['SITE_CONTACT_GATEWAY'];
$MYSQL_PROVISION_DATABASE_PORT = $_ENV['PROVISION_MSQL_DATABASE_IP'] . ":" . $_ENV['PROVISION_MSQL_DATABASE_PORT']; // "172.16.4.96:3307";
$destinationHomeFolder = $_ENV['DESTINATION_HOME_FOLDER'] . $ContainerName;
$templateRandom = 'P' . rand(1, 6);
$composer_template_contents = str_replace("DESTINATION_FOLDER", $destinationHomeFolder, $composer_template_contents);
$composer_template_contents = str_replace("ALLOCATED_PORT", $allocatedPort, $composer_template_contents);
$composer_template_contents = str_replace("CNT_DB_NAME", $ContainerName, $composer_template_contents);
$composer_template_contents = str_replace("CNT_DB_PASS", $provisionUID, $composer_template_contents);
$composer_template_contents = str_replace("CNT_DB_DATA", $MYSQL_PROVISION_DATABASE_PORT, $composer_template_contents);
$composer_template_contents = str_replace("PROVISION_UID_REPLACE", $provisionUID, $composer_template_contents);
$composer_template_contents = str_replace("PROVISION_IMAGE_NAME_REPLACE", "registry.chiefsoft.com/pweb/pweb-01-merms-pweb0006c:latest", $composer_template_contents);
$composer_template_contents = str_replace("SITE_CONTENTS_URL_REPLACE", $SITE_CONTENTS_GATEWAY, $composer_template_contents);
$composer_template_contents = str_replace("SITE_CONTACT_URL_REPLACE", $SITE_CONTACT_GATEWAY, $composer_template_contents);
$composer_template_contents = str_replace("TEMPLATE_NAME_REPLACE", $templateRandom, $composer_template_contents);
return $composer_template_contents;
}
private function scheduleRefreshAction()
{
$mysql = "SELECT * FROM member_product_refresh WHERE product_id IN ('A000001','A000002') AND status =0 LIMIT 1";