Add DOCKERONLYSITES option where no sites.json file is required

This commit is contained in:
Dale Davies
2023-04-14 11:47:17 +01:00
parent c01bc0d815
commit 658e92f0a8
2 changed files with 13 additions and 8 deletions

View File

@@ -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 === '') {

View File

@@ -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".