-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-configs.php
executable file
·68 lines (56 loc) · 1.65 KB
/
build-configs.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
#!/usr/bin/php
<?php
$phpVersions = [
'5.6',
'7.0',
'7.1',
'7.2',
'7.3',
'7.4',
'8.0',
'8.1',
'8.2',
'8.3',
];
$filesToCopy = [
'entrypoint.sh',
'apache2-foreground.sh',
'sudoers',
'vhost.conf',
'remoteip.conf',
'trusted-proxies.lst',
];
$executableFiles = [
'entrypoint.sh',
'apache2-foreground.sh',
];
$dockerfileTemplate = file_get_contents('Dockerfile.template');
foreach ($phpVersions as $phpVersion) {
printf("Building php%s config\n", $phpVersion);
$dirName = 'php' . $phpVersion;
if (!is_dir($dirName)) {
if (!mkdir($dirName, 0755)) {
die(sprintf("Failed to create directory %s\n", $dirName));
}
}
foreach ($filesToCopy as $fileName) {
if (!copy($fileName, $dirName . '/' . $fileName)) {
die(sprintf("Failed to copy file %s\n", $fileName));
}
}
foreach ($executableFiles as $fileName) {
chmod($dirName . '/' . $fileName, 0755);
}
$phpPackagesFile = sprintf('packages-php%s.txt', $phpVersion);
$phpPackages = trim(str_replace("\n", ' ', file_get_contents($phpPackagesFile)));
$fixes = '';
$fixesFile = sprintf('fixes-php%s.txt', $phpVersion);
if (file_exists($fixesFile)) {
$fixes = file_get_contents($fixesFile);
}
$dockerfile = $dockerfileTemplate;
$dockerfile = str_replace('##php-version##', $phpVersion, $dockerfile);
$dockerfile = str_replace('##php-packages##', $phpPackages, $dockerfile);
$dockerfile = str_replace('##fixes##', $fixes, $dockerfile);
file_put_contents($dirName . '/Dockerfile', $dockerfile);
}