-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerator
executable file
·68 lines (57 loc) · 2.02 KB
/
generator
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/env php
<?php
const alpine_version = '3.18';
const debian_version = 'bullseye';
class DockerfileGenerator
{
protected $debian_versions = ['8.1', '8.2', '8.3', '8.4'];
protected $alpine_versions = ['8.1-alpine', '8.2-alpine', '8.3-alpine', '8.4-alpine'];
protected $alpine_zts_versions = ['8.1-zts-alpine', '8.2-zts-alpine', '8.3-zts-alpine', '8.4-zts-alpine'];
protected $debian_zts_versions = ['8.1-zts', '8.2-zts', '8.3-zts', '8.4-zts'];
protected $baseImageTag = [
'8.4' => '8.4.0RC2-bullseye',
'8.4-zts' => '8.4.0RC2-zts-bullseye',
'8.4-alpine' => '8.4.0RC2-alpine3.20',
'8.4-zts-alpine' => '8.4.0RC2-zts-alpine3.20',
];
private function render($version, $type)
{
$v = strstr($version, '-', true) ?: $version;
$CFLAGS = 'CFLAGS="$CFLAGS -D_GNU_SOURCE"';
$alpine = str_contains($version, 'alpine');
if (isset($this->baseImageTag[$version])) {
$tag = $this->baseImageTag[$version];
} else {
if (!$alpine) {
$tag = $version . '-' . debian_version;
} else {
$tag = $version . alpine_version;
}
}
ob_start();
include __DIR__ . '/templates/' . $type . '.php';
$content = ob_get_clean();
$dockerFile = __DIR__ . '/' . $version . '/Dockerfile';
if (!is_dir(dirname($dockerFile))) {
mkdir(dirname($dockerFile));
}
file_put_contents($dockerFile, $content);
}
public function make()
{
foreach ($this->debian_versions as $v) {
$this->render($v, 'debian');
}
foreach ($this->alpine_versions as $v) {
$this->render($v, 'alpine');
}
foreach ($this->debian_zts_versions as $v) {
$this->render($v, 'debian');
}
foreach ($this->alpine_zts_versions as $v) {
$this->render($v, 'alpine');
}
echo "Generate Dockerfile Success!\n";
}
}
(new DockerfileGenerator())->make();