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 | * Process result with returned code and output |
||
126 | * |
||
127 | * @param array $result The result of command with output and returnCode |
||
128 | * |
||
129 | * @throws DockerInstallationMissingException When returned code is 127 |
||
130 | * @throws ComposeFileNotFoundException When no compose file precise and docker-compose.yml not found |
||
131 | * @throws DockerHostConnexionErrorException When we can't connect to docker host |
||
132 | * @throws \Exception When an unknown error is returned |
||
133 | */ |
||
134 | private function processResult($result) |
||
154 | |||
155 | /** |
||
156 | * Create the composeFileCollection from the type of value given |
||
157 | * |
||
158 | * @param mixed $composeFiles The docker-compose files (can be array, string or ComposeFile) |
||
159 | * |
||
160 | * @return ComposeFileCollection |
||
161 | */ |
||
162 | private function createComposeFileCollection($composeFiles) |
||
174 | |||
175 | /** |
||
176 | * Format the command to execute |
||
177 | * |
||
178 | * @param string $subcommand The subcommand to pass to docker-compose command |
||
179 | * @param ComposeFileCollection $composeFiles The compose files to precise in the command |
||
180 | */ |
||
181 | private function formatCommand($subcommand, ComposeFileCollection $composeFiles) |
||
208 | |||
209 | /** |
||
210 | * Execute docker-compose commande |
||
211 | * @codeCoverageIgnore |
||
212 | * @param string $command The command to execute |
||
213 | */ |
||
214 | protected function execute($command) |
||
229 | } |
||
230 |