From 658e92f0a807afc2679bb3d9ce007e2811aa43e6 Mon Sep 17 00:00:00 2001 From: Dale Davies Date: Fri, 14 Apr 2023 11:47:17 +0100 Subject: [PATCH] Add DOCKERONLYSITES option where no sites.json file is required --- jumpapp/classes/Sites.php | 18 ++++++++++-------- jumpapp/config.php | 3 +++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/jumpapp/classes/Sites.php b/jumpapp/classes/Sites.php index 48adb96..a94d37e 100644 --- a/jumpapp/classes/Sites.php +++ b/jumpapp/classes/Sites.php @@ -159,16 +159,18 @@ class Sites { }; $allsites = []; + // If we have been instructed to only look for sites via docker then + // don't worry about loading a local sites.json file and just + // return an empty $allsites array. + if ($this->config->get('dockeronlysites')) { + if (!$docker()) { + throw new ConfigException('DOCKERONLYSITES is specified but no Docker endpoint has been provided'); + } + return $allsites; + } + // Try to load the sites.json file. $rawjson = @file_get_contents($this->sitesfilelocation); if ($rawjson === false) { - // If we have been instructed to look for docker sites then - // don't worry about not having a local sites.json file and just - // return an empty $allsites array. - if ($docker()) { - return $allsites; - } - // If we are not supposed to have docker sites then complau=in about - // not being able to load a sites.json. throw new ConfigException('There was a problem loading the sites.json file'); } if ($rawjson === '') { diff --git a/jumpapp/config.php b/jumpapp/config.php index 709807d..5e20123 100644 --- a/jumpapp/config.php +++ b/jumpapp/config.php @@ -74,6 +74,9 @@ return [ // Duration to cache status in minutes. 'statuscache' => getenv('STATUSCACHE') ?: '5', + // Only try to look for sites via Docker rather than first trying to load + // the sites.json file. + 'dockeronlysites' => getenv('DOCKERONLYSITES') ?: false, // The URL and port on which a docker socket proxy is listening, for example // if you have tecnativa/docker-socket-proxy named dockerproxy listening on // port 2375 then this would be "dockerproxy:2375".