1 | <?php |
||
16 | class ComposeManager |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * Start service containers |
||
21 | * |
||
22 | * @param mixed $composeFiles The compose files names |
||
23 | */ |
||
24 | public function start($composeFiles = array()) |
||
32 | |||
33 | /** |
||
34 | * Stop service containers |
||
35 | * |
||
36 | * @param mixed $composeFiles The compose files names |
||
37 | */ |
||
38 | public function stop($composeFiles = array()) |
||
46 | |||
47 | /** |
||
48 | * Stop service containers |
||
49 | * |
||
50 | * @param mixed $composeFiles The compose files names |
||
51 | * @param boolean $force If the remove need to be force (default=false) |
||
52 | * @param boolean $removeVolumes If we need to remove the volumes (default=false) |
||
53 | */ |
||
54 | public function remove($composeFiles = array(), $force = false, $removeVolumes = false) |
||
71 | |||
72 | /** |
||
73 | * Build service images |
||
74 | * |
||
75 | * @param mixed $composeFiles The compose files names |
||
76 | * @param boolean $pull If we want attempt to pull a newer version of the from image |
||
77 | * @param boolean $forceRemove If we want remove the intermediate containers |
||
78 | * @param bollean $cache If we can use the cache when building the image |
||
79 | */ |
||
80 | public function build($composeFiles = array(), $pull = true, $forceRemove = false, $cache = true) |
||
102 | |||
103 | |||
104 | /** |
||
105 | * Restart running containers |
||
106 | * |
||
107 | * @param mixed $composeFiles The compose files names |
||
108 | * @param integer $timeout If we want attempt to pull a newer version of the from image |
||
109 | */ |
||
110 | public function restart($composeFiles = array(), $timeout = 10) |
||
124 | |||
125 | /** |
||
126 | * Run service with command |
||
127 | * |
||
128 | * @param string $service Service name |
||
129 | * @param string $command Command to pass to service |
||
130 | * @param mixed $composeFiles The compose files names |
||
131 | */ |
||
132 | public function run($service, $command, $composeFiles = array()) |
||
145 | |||
146 | /** |
||
147 | * Process result with returned code and output |
||
148 | * |
||
149 | * @param array $result The result of command with output and returnCode |
||
150 | * |
||
151 | * @throws DockerInstallationMissingException When returned code is 127 |
||
152 | * @throws ComposeFileNotFoundException When no compose file precise and docker-compose.yml not found |
||
153 | * @throws DockerHostConnexionErrorException When we can't connect to docker host |
||
154 | * @throws \Exception When an unknown error is returned |
||
155 | */ |
||
156 | private function processResult($result) |
||
176 | |||
177 | /** |
||
178 | * Create the composeFileCollection from the type of value given |
||
179 | * |
||
180 | * @param mixed $composeFiles The docker-compose files (can be array, string or ComposeFile) |
||
181 | * |
||
182 | * @return ComposeFileCollection |
||
183 | */ |
||
184 | private function createComposeFileCollection($composeFiles) |
||
196 | |||
197 | /** |
||
198 | * Format the command to execute |
||
199 | * |
||
200 | * @param string $subcommand The subcommand to pass to docker-compose command |
||
201 | * @param ComposeFileCollection $composeFiles The compose files to precise in the command |
||
202 | */ |
||
203 | private function formatCommand($subcommand, ComposeFileCollection $composeFiles) |
||
230 | |||
231 | /** |
||
232 | * Execute docker-compose commande |
||
233 | * @codeCoverageIgnore |
||
234 | * @param string $command The command to execute |
||
235 | */ |
||
236 | protected function execute($command) |
||
251 | } |
||
252 |