-
Notifications
You must be signed in to change notification settings - Fork 2
/
generator
executable file
·63 lines (54 loc) · 1.68 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
#!/usr/bin/env php
<?php
const alpine_version = '3.18';
const debian_version = 'bullseye';
function render($version, $type)
{
$v = strstr($version, '-', true) ?: $version;
if (version_compare($v, '8.0', '>=') or $v == 'rc' or $v == 'latest' or $v == 'alpine') {
$CFLAGS = 'CFLAGS="$CFLAGS -D_GNU_SOURCE"';
} else {
$CFLAGS = '';
}
$alpine = str_contains($version, 'alpine');
if (!$alpine) {
// 7.2 does not have bullseye
if ($version === '7.2') {
$tag = $version;
} elseif ($version === 'rc' or $version == 'latest') {
$tag = debian_version;
} else {
$tag = $version . '-' . debian_version;
}
} else {
if (version_compare($v, '8.1', '>=')) {
$tag = $version . alpine_version;
} else {
$tag = $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);
}
$debian_versions = ['8.1', '8.2', '8.3', 'rc', 'latest'];
foreach ($debian_versions as $v) {
render($v, 'debian');
}
$alpine_versions = ['8.1-alpine', '8.2-alpine', '8.3-alpine', 'rc-alpine', 'alpine'];
foreach ($alpine_versions as $v) {
render($v, 'alpine');
}
$debian_zts_versions = ['8.1-zts', '8.2-zts', '8.3-zts'];
foreach ($debian_zts_versions as $v) {
render($v, 'debian');
}
$alpine_zts_versions = ['8.1-zts-alpine', '8.2-zts-alpine', '8.3-zts-alpine'];
foreach ($alpine_zts_versions as $v) {
render($v, 'alpine');
}