diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/composer.json b/composer.json index 38bb841..52b202a 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,8 @@ "fabpot/goutte": "^3.2", "guzzlehttp/guzzle": "~6.0", "yadakhov/insert-on-duplicate-key": "^0.0.9", - "docker-php/docker-php": "^1.24" + "docker-php/docker-php": "^1.24", + "symfony/process": "^3.2.*" }, "autoload": { "psr-4": { diff --git a/src/Docker.php b/src/Docker.php index 9a934a1..817fad6 100644 --- a/src/Docker.php +++ b/src/Docker.php @@ -30,10 +30,10 @@ class Docker public function __construct(\Docker\Docker $docker) { $client = new DockerClient([ - 'remote_socket' => getenv('DOCKER_SOCKET') ? : 'unix:///var/run/docker.sock', + 'remote_socket' => getenv('DOCKER_SOCKET') ?: 'unix:///var/run/docker.sock', ]); - $this->client= new $docker($client); + $this->client = new $docker($client); } /** @@ -73,6 +73,7 @@ public function isNamedContainerRunning($name) return true; } } + return false; } @@ -105,17 +106,18 @@ public function getNamedContainerPorts($name) $containerManager = $this->client->getContainerManager(); $containers = $containerManager->findAll(); - $ports = []; - foreach ($containers as $container) { if ($container->getNames()[0] == "/".$name) { $containerPorts = $container->getPorts(); foreach ($containerPorts as $port) { $ports[] = $port->getPrivatePort(); } + + return $ports; } } - return $ports; + + return []; } /** @@ -153,6 +155,7 @@ public function imageExists($tag) return true; } } + return false; } diff --git a/src/DockerServicesCommand.php b/src/DockerServices.php similarity index 96% rename from src/DockerServicesCommand.php rename to src/DockerServices.php index fc6768e..c462e17 100644 --- a/src/DockerServicesCommand.php +++ b/src/DockerServices.php @@ -6,11 +6,11 @@ use Exception; /** - * Class DockerServicesCommand + * Class DockerServices * * @package luisgros */ -class DockerServicesCommand extends Command +class DockerServices extends Command { /** * The name and signature of the console command. @@ -25,7 +25,7 @@ class DockerServicesCommand extends Command */ protected $description = 'Setup docker environment'; /** - * The console command description. + * The services * * @var string */ @@ -60,14 +60,14 @@ class DockerServicesCommand extends Command ], ]; /** - * @var \App\Console\Commands\Docker + * @var Docker */ protected $docker; /** * Create a new command instance. * - * @param \luisgros\Docker $docker + * @param Docker $docker */ public function __construct(Docker $docker) { @@ -77,7 +77,7 @@ public function __construct(Docker $docker) } /** - * @throws \Exception + * @throws Exception */ public function handle() {