-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.php
72 lines (55 loc) · 1.41 KB
/
build.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
61
62
63
64
65
66
67
68
69
70
71
72
<?php
echo "Build Dockerfile!\n";
$tags = ["5.4","5.5","5.6"];
$sapi = ["apache","cli","fpm"];
$mods = [
"5.5" => ["opcache"],
"5.6" => ["opcache"],
];
$versions = '';
foreach ($tags as $tag) {
$versions .= "* {$tag} [(Dockerfile)]({$tag}/cli/Dockerfile)\n";
foreach ($sapi as $sap) {
$versions .= " * {$tag}-{$sap} [(Dockerfile)]({$tag}/{$sap}/Dockerfile)\n";
writeFile($tag, $sap);
}
}
function writeFile($version = NULL, $type = NULL) {
chdir($_SERVER["PWD"]);
$dockerfile = dockerFile($version, $type);
if (! is_null($version)) {
if(! is_dir($version)) mkdir($version);
chdir($version);
}
if (! is_null($type)) {
if(! is_dir($type)) mkdir($type);
chdir($type);
}
return file_put_contents('Dockerfile', $dockerfile);
}
function dockerFile($version = NULL, $type = NULL) {
$require = file_get_contents("require");
$configs = file_get_contents("configure");
$install = file_get_contents("install");
$cleanup = file_get_contents("cleanup");
$tag = '';
if (! is_null($version) or ! is_null($type)) {
$tag .= ":".$version;
if (! is_null($version) and ! is_null($type)) $tag .= "-";
$tag .= $type;
}
$from = "FROM php".$tag."\n";
return $from."\n".
$require.
$configs.
$install.
mods($version).
$cleanup;
}
function mods($version) {
global $mods;
$mod = '';
if (array_key_exists($version, $mods))
$mod .= " ".implode($mods[$version], " \\\n ")." \\\n";
return $mod;
}