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 | * List containers |
||
148 | * |
||
149 | * @param mixed $composeFiles The compose files names |
||
150 | */ |
||
151 | public function ps($composeFiles = array()) |
||
159 | |||
160 | /** |
||
161 | * Process result with returned code and output |
||
162 | * |
||
163 | * @param array $result The result of command with output and returnCode |
||
164 | * |
||
165 | * @throws DockerInstallationMissingException When returned code is 127 |
||
166 | * @throws ComposeFileNotFoundException When no compose file precise and docker-compose.yml not found |
||
167 | * @throws DockerHostConnexionErrorException When we can't connect to docker host |
||
168 | * @throws \Exception When an unknown error is returned |
||
169 | */ |
||
170 | private function processResult($result) |
||
190 | |||
191 | /** |
||
192 | * Create the composeFileCollection from the type of value given |
||
193 | * |
||
194 | * @param mixed $composeFiles The docker-compose files (can be array, string or ComposeFile) |
||
195 | * |
||
196 | * @return ComposeFileCollection |
||
197 | */ |
||
198 | private function createComposeFileCollection($composeFiles) |
||
210 | |||
211 | /** |
||
212 | * Format the command to execute |
||
213 | * |
||
214 | * @param string $subcommand The subcommand to pass to docker-compose command |
||
215 | * @param ComposeFileCollection $composeFiles The compose files to precise in the command |
||
216 | */ |
||
217 | private function formatCommand($subcommand, ComposeFileCollection $composeFiles) |
||
244 | |||
245 | /** |
||
246 | * Execute docker-compose commande |
||
247 | * @codeCoverageIgnore |
||
248 | * @param string $command The command to execute |
||
249 | */ |
||
250 | protected function execute($command) |
||
265 | } |
||
266 |