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 | * Run service with command |
||
105 | * |
||
106 | * @param string $service Service name |
||
107 | * @param string $command Command to pass to service |
||
108 | * @param mixed $composeFiles The compose files names |
||
109 | */ |
||
110 | public function run($service, $command, $composeFiles = array()) |
||
123 | |||
124 | /** |
||
125 | * List containers |
||
126 | * |
||
127 | * @param mixed $composeFiles The compose files names |
||
128 | */ |
||
129 | public function ps($composeFiles = array()) |
||
137 | |||
138 | /** |
||
139 | * Process result with returned code and output |
||
140 | * |
||
141 | * @param array $result The result of command with output and returnCode |
||
142 | * |
||
143 | * @throws DockerInstallationMissingException When returned code is 127 |
||
144 | * @throws ComposeFileNotFoundException When no compose file precise and docker-compose.yml not found |
||
145 | * @throws DockerHostConnexionErrorException When we can't connect to docker host |
||
146 | * @throws \Exception When an unknown error is returned |
||
147 | */ |
||
148 | private function processResult($result) |
||
168 | |||
169 | /** |
||
170 | * Create the composeFileCollection from the type of value given |
||
171 | * |
||
172 | * @param mixed $composeFiles The docker-compose files (can be array, string or ComposeFile) |
||
173 | * |
||
174 | * @return ComposeFileCollection |
||
175 | */ |
||
176 | private function createComposeFileCollection($composeFiles) |
||
188 | |||
189 | /** |
||
190 | * Format the command to execute |
||
191 | * |
||
192 | * @param string $subcommand The subcommand to pass to docker-compose command |
||
193 | * @param ComposeFileCollection $composeFiles The compose files to precise in the command |
||
194 | */ |
||
195 | private function formatCommand($subcommand, ComposeFileCollection $composeFiles) |
||
222 | |||
223 | /** |
||
224 | * Execute docker-compose commande |
||
225 | * @codeCoverageIgnore |
||
226 | * @param string $command The command to execute |
||
227 | */ |
||
228 | protected function execute($command) |
||
243 | } |
||
244 |