|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Dock\Installer\DNS\Mac; |
|
4
|
|
|
|
|
5
|
|
|
use Dock\Docker\Machine\DockerMachineCli; |
|
6
|
|
|
use Dock\Installer\InstallerTask; |
|
7
|
|
|
use Dock\IO\ProcessRunner; |
|
8
|
|
|
use Dock\IO\UserInteraction; |
|
9
|
|
|
use SRIO\ChainOfResponsibility\DependentChainProcessInterface; |
|
10
|
|
|
|
|
11
|
|
|
class DownloadDnsDock extends InstallerTask implements DependentChainProcessInterface |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var UserInteraction |
|
15
|
|
|
*/ |
|
16
|
|
|
private $userInteraction; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var ProcessRunner |
|
20
|
|
|
*/ |
|
21
|
|
|
private $processRunner; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var DockerMachineCli |
|
25
|
|
|
*/ |
|
26
|
|
|
private $machine; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @param UserInteraction $userInteraction |
|
30
|
|
|
* @param ProcessRunner $processRunner |
|
31
|
|
|
* @param DockerMachineCli $machine |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __construct(UserInteraction $userInteraction, ProcessRunner $processRunner, DockerMachineCli $machine) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->userInteraction = $userInteraction; |
|
36
|
|
|
$this->processRunner = $processRunner; |
|
37
|
|
|
$this->machine = $machine; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* {@inheritdoc} |
|
42
|
|
|
*/ |
|
43
|
|
|
public function run() |
|
44
|
|
|
{ |
|
45
|
|
|
$this->userInteraction->writeTitle("Pulling image tonistiigi/dnsdock"); |
|
46
|
|
|
$this->userInteraction->write("Check docker machine is running"); |
|
47
|
|
|
if (!$this->machine->isRunning()) { |
|
48
|
|
|
$this->userInteraction->write("Starting machine"); |
|
49
|
|
|
$this->machine->start(); |
|
50
|
|
|
} |
|
51
|
|
|
$this->userInteraction->write("Setting environment variables"); |
|
52
|
|
|
$this->processRunner->run($this->machine->getEnvironmentDeclaration()); |
|
53
|
|
|
|
|
54
|
|
|
$this->userInteraction->write("Pulling image tonistiigi/dnsdock, this could take a while when run for the first time"); |
|
55
|
|
|
$this->processRunner->run('docker pull tonistiigi/dnsdock'); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* {@inheritdoc} |
|
60
|
|
|
*/ |
|
61
|
|
|
public function dependsOn() |
|
62
|
|
|
{ |
|
63
|
|
|
return ['machine']; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* {@inheritdoc} |
|
68
|
|
|
*/ |
|
69
|
|
|
public function getName() |
|
70
|
|
|
{ |
|
71
|
|
|
return 'dnsdock_image'; |
|
72
|
|
|
} |
|
73
|
|
|
} |