forked from orangehrm/orangehrm-dev-environment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
env-start.php
60 lines (50 loc) · 2.07 KB
/
env-start.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
require_once('./utils/climate/autoload.php');
$climate = new League\CLImate\CLImate;
$climate->out('');
$climate->addArt('./utils/banners');
$climate->yellow()->animation('welcome')->speed(100)->enterFrom('bottom');
$climate->br();
$docker_status = shell_exec('service docker status');
if (strpos($docker_status, 'active (running)') !== false) {
$basicOrCustom = ['Basic Environment', 'Custom Environment'];
$inputSelectEnvType = $climate->radio("Please select the environment you want",$basicOrCustom);
$environmentTypeSelected = $inputSelectEnvType->prompt();
if($environmentTypeSelected == "Basic Environment"){
$fullCommand = "docker-compose up -d";
}else{
$CustomOptions = [
'./custom-compose/web70.yml' => 'PHP 7.0',
'./custom-compose/ubuntuweb71.yml' => 'Ubuntu 18.04 - PHP 7.1',
'./custom-compose/db56.yml' => 'MySQL 5.6',
'./custom-compose/db55.yml' => 'MySQL 5.5',
'./custom-compose/mariadb103.yml' => 'MariaDB 10.3',
];
$inputCustomContainerSelection = $climate->br()->checkboxes('Please select custom containers you need', $CustomOptions);
$customContainersSelected = $inputCustomContainerSelection->prompt();
$climate->br();
$climate->br();
if(count($customContainersSelected) > 0){
$fullCommand = "docker-compose -f docker-compose.yml".generateCustomCommand($customContainersSelected)." up -d";
}else{
$fullCommand = "docker-compose up -d";
}
}
$climate->br();
$climate->br();
$climate->blue()->out("Starting the Environment ...");
$climate->br();
$docker_dev = shell_exec($fullCommand);
$climate->br();
$climate->green()->out("SUCCESSFUL!");
}else{
$climate->error('Please make sure Docker service is running. Run "service docker start"');
}
$climate->br();
function generateCustomCommand($customComposeFiles){
$command = "";
foreach ($customComposeFiles as $customComposeFile){
$command .= " -f ".$customComposeFile;
}
return $command;
}