Debuggin' whats wrong with service detection.
This commit is contained in:
parent
02e1cd19de
commit
a909cba332
2 changed files with 26 additions and 5 deletions
|
@ -6,6 +6,13 @@ services:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
target: loadbalancer
|
target: loadbalancer
|
||||||
|
args:
|
||||||
|
MAINTAINER: "Test <test@oneupsales.co.uk>"
|
||||||
|
SOURCE_URL: "https://github.com/doesntmatter"
|
||||||
|
GIT_SHA: "1234"
|
||||||
|
GIT_BUILD_ID: "test"
|
||||||
|
GIT_COMMIT_MESSAGE: "testy mctestface"
|
||||||
|
BUILD_DATE: "1970-01-01"
|
||||||
additional_contexts:
|
additional_contexts:
|
||||||
- php:cli=docker-image://ghcr.io/benzine-framework/php:cli-8.2
|
- php:cli=docker-image://ghcr.io/benzine-framework/php:cli-8.2
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
@ -8,16 +8,19 @@ use AdamBrett\ShellWrapper\Command\Builder as CommandBuilder;
|
||||||
use AdamBrett\ShellWrapper\Runners\Exec;
|
use AdamBrett\ShellWrapper\Runners\Exec;
|
||||||
use Aws\S3\S3Client;
|
use Aws\S3\S3Client;
|
||||||
use Bouncer\Logger\AbstractLogger;
|
use Bouncer\Logger\AbstractLogger;
|
||||||
|
use Bouncer\Logger\Formatter;
|
||||||
|
use Bouncer\Logger\Logger;
|
||||||
|
use Bouncer\Settings\Settings;
|
||||||
use GuzzleHttp\Client as Guzzle;
|
use GuzzleHttp\Client as Guzzle;
|
||||||
use GuzzleHttp\Exception\ConnectException;
|
use GuzzleHttp\Exception\ConnectException;
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
use GuzzleHttp\Exception\ServerException;
|
use GuzzleHttp\Exception\ServerException;
|
||||||
use League\Flysystem\AwsS3V3\AwsS3V3Adapter;
|
use League\Flysystem\AwsS3V3\AwsS3V3Adapter;
|
||||||
use League\Flysystem\FileAttributes;
|
use League\Flysystem\FileAttributes;
|
||||||
use League\Flysystem\Filesystem;
|
use League\Flysystem\Filesystem;
|
||||||
use League\Flysystem\FilesystemException;
|
use League\Flysystem\FilesystemException;
|
||||||
use League\Flysystem\Local\LocalFilesystemAdapter;
|
use League\Flysystem\Local\LocalFilesystemAdapter;
|
||||||
use Bouncer\Logger\Logger;
|
use Monolog\Processor;
|
||||||
use Bouncer\Logger\Formatter;
|
|
||||||
use Spatie\Emoji\Emoji;
|
use Spatie\Emoji\Emoji;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
use Twig\Environment as Twig;
|
use Twig\Environment as Twig;
|
||||||
|
@ -25,9 +28,6 @@ use Twig\Error\LoaderError;
|
||||||
use Twig\Error\RuntimeError;
|
use Twig\Error\RuntimeError;
|
||||||
use Twig\Error\SyntaxError;
|
use Twig\Error\SyntaxError;
|
||||||
use Twig\Loader\FilesystemLoader as TwigLoader;
|
use Twig\Loader\FilesystemLoader as TwigLoader;
|
||||||
use GuzzleHttp\Exception\GuzzleException;
|
|
||||||
use Monolog\Processor;
|
|
||||||
use Bouncer\Settings\Settings;
|
|
||||||
|
|
||||||
class Bouncer
|
class Bouncer
|
||||||
{
|
{
|
||||||
|
@ -186,6 +186,7 @@ class Bouncer
|
||||||
public function findContainersContainerMode(): array
|
public function findContainersContainerMode(): array
|
||||||
{
|
{
|
||||||
$bouncerTargets = [];
|
$bouncerTargets = [];
|
||||||
|
$this->logger->warning('Interrogating CONTAINERS for BOUNCER_* environment variables.', ['emoji' => Emoji::magnifyingGlassTiltedLeft()]);
|
||||||
|
|
||||||
$containers = json_decode($this->docker->request('GET', 'containers/json')->getBody()->getContents(), true);
|
$containers = json_decode($this->docker->request('GET', 'containers/json')->getBody()->getContents(), true);
|
||||||
foreach ($containers as $container) {
|
foreach ($containers as $container) {
|
||||||
|
@ -262,11 +263,14 @@ class Bouncer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->logger->warning('Interrogating CONTAINERS for BOUNCER_* environment variables found {count} containers.', ['emoji' => Emoji::magnifyingGlassTiltedLeft(), 'count' => count($validBouncerTargets)]);
|
||||||
|
|
||||||
return $validBouncerTargets;
|
return $validBouncerTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findContainersSwarmMode(): array
|
public function findContainersSwarmMode(): array
|
||||||
{
|
{
|
||||||
|
$this->logger->warning('Interrogating SERVICES for BOUNCER_* environment variables.', ['emoji' => Emoji::magnifyingGlassTiltedLeft()]);
|
||||||
$bouncerTargets = [];
|
$bouncerTargets = [];
|
||||||
$services = json_decode($this->docker->request('GET', 'services')->getBody()->getContents(), true);
|
$services = json_decode($this->docker->request('GET', 'services')->getBody()->getContents(), true);
|
||||||
|
|
||||||
|
@ -365,6 +369,8 @@ class Bouncer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->logger->warning('Interrogating SERVICES for BOUNCER_* environment variables found {count} containers.', ['emoji' => Emoji::magnifyingGlassTiltedLeft(), 'count' => count($validBouncerTargets)]);
|
||||||
|
|
||||||
return $validBouncerTargets;
|
return $validBouncerTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,6 +676,7 @@ class Bouncer
|
||||||
|
|
||||||
$this->logger->debug(' > Swarm mode is {enabled}.', ['emoji' => Emoji::honeybee(), 'enabled' => $this->isSwarmMode() ? 'enabled' : 'disabled']);
|
$this->logger->debug(' > Swarm mode is {enabled}.', ['emoji' => Emoji::honeybee(), 'enabled' => $this->isSwarmMode() ? 'enabled' : 'disabled']);
|
||||||
|
|
||||||
|
/** @var Target[] $targets */
|
||||||
$targets = array_values(
|
$targets = array_values(
|
||||||
array_merge(
|
array_merge(
|
||||||
$this->findContainersContainerMode(),
|
$this->findContainersContainerMode(),
|
||||||
|
@ -677,6 +684,13 @@ class Bouncer
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
foreach($targets as $target){
|
||||||
|
$this->logger->info('Found target {target}', ['emoji' => Emoji::magnifyingGlassTiltedLeft(), 'target' => $target->getName()]);
|
||||||
|
\Kint::dump(
|
||||||
|
$target->getDomains(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Use some bs to sort the targets by domain from right to left.
|
// Use some bs to sort the targets by domain from right to left.
|
||||||
$sortedTargets = [];
|
$sortedTargets = [];
|
||||||
foreach ($targets as $target) {
|
foreach ($targets as $target) {
|
||||||
|
|
Loading…
Reference in a new issue