From 7dd9e23a0412c8db8df59789df752d22332d8930 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Sun, 5 Oct 2025 15:46:15 -0400 Subject: [PATCH] merm compatible --- .env | 75 ++--------------------------- app/Controllers/BaseController.php | 61 +++++++++++++++++++++++ app/Controllers/Home.php | 3 ++ app/Views/errors/html/error_404.php | 38 +++++++++++---- app/Views/layouts/master.php | 4 +- docker-compose.yml | 17 +++++-- push-images.sh | 57 ++++++++++++++++++++++ 7 files changed, 169 insertions(+), 86 deletions(-) create mode 100644 push-images.sh diff --git a/.env b/.env index ccbed2b..5445d97 100644 --- a/.env +++ b/.env @@ -1,71 +1,6 @@ -CONTAINER_PORT=62100 +APP_PORT=62100 UID=1000 -#-------------------------------------------------------------------- -# Example Environment Configuration file -# -# This file can be used as a starting point for your own -# custom .env files, and contains most of the possible settings -# available in a default install. -# -# By default, all of the settings are commented out. If you want -# to override the setting, you must un-comment it by removing the '#' -# at the beginning of the line. -#-------------------------------------------------------------------- - -#-------------------------------------------------------------------- -# ENVIRONMENT -#-------------------------------------------------------------------- - -# CI_ENVIRONMENT = production - -#-------------------------------------------------------------------- -# APP -#-------------------------------------------------------------------- - -# app.baseURL = '' -# If you have trouble with `.`, you could also use `_`. -# app_baseURL = '' -# app.forceGlobalSecureRequests = false -# app.CSPEnabled = false - -#-------------------------------------------------------------------- -# DATABASE -#-------------------------------------------------------------------- - -# database.default.hostname = localhost -# database.default.database = ci4 -# database.default.username = root -# database.default.password = root -# database.default.DBDriver = MySQLi -# database.default.DBPrefix = -# database.default.port = 3306 - -# If you use MySQLi as tests, first update the values of Config\Database::$tests. -# database.tests.hostname = localhost -# database.tests.database = ci4_test -# database.tests.username = root -# database.tests.password = root -# database.tests.DBDriver = MySQLi -# database.tests.DBPrefix = -# database.tests.charset = utf8mb4 -# database.tests.DBCollat = utf8mb4_general_ci -# database.tests.port = 3306 - -#-------------------------------------------------------------------- -# ENCRYPTION -#-------------------------------------------------------------------- - -# encryption.key = - -#-------------------------------------------------------------------- -# SESSION -#-------------------------------------------------------------------- - -# session.driver = 'CodeIgniter\Session\Handlers\FileHandler' -# session.savePath = null - -#-------------------------------------------------------------------- -# LOGGER -#-------------------------------------------------------------------- - -# logger.threshold = 4 +PROVISION_UID=3cc24fd6-e6c7-4c08-8a64-f06e3f790f38 +CONTENTS_SERVER="https://devapi.mermsemr.com/web/contents" +CONTENTS_SERVER2="http://10.10.10.101:14700/web/contents" +SITE_CONTACT_URL="https://devapi.mermsemr.com/web/contacts" diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 8b435da..fe8bcf1 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -55,4 +55,65 @@ abstract class BaseController extends Controller // E.g.: $this->session = \Config\Services::session(); } + + public function getenv_docker($env, $default) + { + if ($fileEnv = getenv($env . '_FILE')) { + return rtrim(file_get_contents($fileEnv), "\r\n"); + } else if (($val = getenv($env)) !== false) { + return $val; + } else { + return $default; + } + } + + public function ExternalAPICall($method, $url, $data) + { + // $curl = curl_init(); + $curl = curl_init($url); + switch ($method) { + case "GET": + $params2 = ''; + foreach ($data as $key2 => $value2) + $params2 .= $key2 . '=' . $value2 . '&'; + + $params2 = trim($params2, '&'); + $url = $url . '?' . $params2;// add param to URL + log_message('critical', "API URL FINAL =>" . $url); + //curl_setopt($curl, CURLOPT_FRESH_CONNECT, true); + //curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + //curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); + break; + case "POST": + curl_setopt($curl, CURLOPT_POST, 1); + if ($data) + // curl_setopt($curl, CURLOPT_POSTFIELDS, $data); + curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); + // curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); + break; + case "PUT": + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); + if ($data) + curl_setopt($curl, CURLOPT_POSTFIELDS, $data); + break; + } + + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_HTTPHEADER, array( + 'APIKEY: RegisteredAPIkey', + 'Content-Type: application/json', + )); + + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + $result = curl_exec($curl); + + if (!$result) { + //echo("Connection failure!"); + log_message('critical', "API Connection failure! =>" . $url); + + } + curl_close($curl); + return json_decode($result, true); + } } diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index c2f40c7..7a8f0d8 100644 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -16,6 +16,9 @@ class Home extends BaseController public function contacts(): string { + if($_POST){ + // var_dump( $_POST ); + } return view('contacts'); } diff --git a/app/Views/errors/html/error_404.php b/app/Views/errors/html/error_404.php index e506f08..004d84e 100644 --- a/app/Views/errors/html/error_404.php +++ b/app/Views/errors/html/error_404.php @@ -15,6 +15,7 @@ left: 50%; margin-left: -73px; } + body { height: 100%; background: #fafafa; @@ -22,6 +23,7 @@ color: #777; font-weight: 300; } + h1 { font-weight: lighter; letter-spacing: normal; @@ -30,6 +32,7 @@ margin-bottom: 0; color: #222; } + .wrap { max-width: 1024px; margin: 5rem auto; @@ -40,10 +43,12 @@ border-radius: 0.5rem; position: relative; } + pre { white-space: normal; margin-top: 1.5rem; } + code { background: #fafafa; border: 1px solid #efefef; @@ -51,9 +56,11 @@ border-radius: 5px; display: block; } + p { margin-top: 1.5rem; } + .footer { margin-top: 2rem; border-top: 1px solid #efefef; @@ -61,24 +68,37 @@ font-size: 85%; color: #999; } + a:active, a:link, a:visited { color: #dd4814; } + + + -
-

404

+
+ -

- - - - - -

+

Page not found

+ +

+ + + + + +

+

+

+ Home | About us | Contacts +
+

+
diff --git a/app/Views/layouts/master.php b/app/Views/layouts/master.php index 9531498..df58d64 100644 --- a/app/Views/layouts/master.php +++ b/app/Views/layouts/master.php @@ -47,11 +47,11 @@
  • Home
  • -
  • About us +
  • About us
  • -
  • Contacts
  • +
  • Contacts
  • diff --git a/docker-compose.yml b/docker-compose.yml index 41bbba7..ee7e984 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,17 +9,24 @@ services: environment: - APACHE_RUN_USER=#${UID} - APACHE_RUN_GROUP=#${UID} - #- CI_ENV + - PROVISION_UID=#${PROVISION_UID} + - CONTENTS_SERVER=#${CONTENTS_SERVER} + - SITE_CONTACT_URL=#${SITE_CONTACT_URL} + - TEMPLATE_NAME=p5 + - PROVISION_UID=3cc24fd6-e6c7-4c08-8a64-f06e3f790f38 - CI_CONFIG restart: unless-stopped volumes: - ./:/var/www/html - ./apache_log:/var/log/apache2 ports: - - "${CONTAINER_PORT}:80" + - "${APP_PORT}:80" extra_hosts: - - "host.docker.internal:host-gateway" - - oameye.works.wrenchboard.com:10.20.30.27 - - oameye.work.wrenchboard.com:10.10.33.15 + - api.mermsemr.com:10.10.33.15 + - devapi.mermsemr.com:10.10.33.15 + - devsocket.mermsemr.com:10.10.33.15 + - socket.mermsemr.com:10.10.33.15 + - dev-media.mermsemr.com:10.10.33.15 + - media.mermsemr.com:10.10.33.15 volumes: src: diff --git a/push-images.sh b/push-images.sh new file mode 100644 index 0000000..20dd0de --- /dev/null +++ b/push-images.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash + +log() { + local message="$1" + echo -e "\033[32mLog: $message\033[0m" +} + +handle_error() { + local error_message="$1" + echo -e "\033[31mError: $error_message\033[0m" + exit 1 +} + +# Retry logic with exponential backoff +# Usage: retry +# e.g.: retry docker compose down --volumes +retry() { + local max_attempts=5 + local attempt=1 + local delay=1 + + while true; do + "$@" && break || { + if [ $attempt -lt $max_attempts ]; then + log "Command failed (attempt $attempt/$max_attempts). Retrying in $delay seconds..." + sleep $delay + delay=$((delay * 2)) + ((attempt++)) + else + handle_error "Command failed after $attempt attempts: $*" + fi + } + done +} + + +################################################################################ +# MAIN +################################################################################ + +if [ "$1" == "push" ]; then + start: + + docker login -u="merms" -p="may12002!" registry.chiefsoft.com + + docker tag mermsicare-mermshosted-icare registry.chiefsoft.com/custom/mermsicare-mermshostedicare-001:latest + docker push registry.chiefsoft.com/custom/mermsicare-mermshostedicare-001:latest + + +elif [ "$1" == "test" ]; then + + start: + docker images + +else + handle_error "Invalid argument. Use 'dev' or 'test'." +fi