This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
generate.py
82 lines (73 loc) · 1.73 KB
/
generate.py
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
73
74
75
76
77
78
79
80
81
82
import logging
from pathlib import Path
from jinja2 import Template
BASE_IMAGES = ["alpine", "buster", "bullseye", "slim"]
PYTHON_VERSIONS = [
"3.8",
"3.8.12",
"3.8.13",
"3.8.14",
"3.8.15",
"3.8.16",
"3.8.17",
"3.8.18",
"3.9",
"3.9.9",
"3.9.10",
"3.9.11",
"3.9.12",
"3.9.13",
"3.9.14",
"3.9.15",
"3.9.16",
"3.9.17",
"3.9.18",
"3.10",
"3.10.0",
"3.10.1",
"3.10.2",
"3.10.3",
"3.10.4",
"3.10.5",
"3.10.6",
"3.10.7",
"3.10.8",
"3.10.9",
"3.10.10",
"3.10.11",
"3.10.12",
"3.10.13",
"3.11",
"3.11.0",
"3.11.1",
"3.11.2",
"3.11.3",
"3.11.4",
"3.11.5",
"3.11.6",
"3.12.0",
]
POETRY_VERSION = "1.6.1"
logging.basicConfig(
level="INFO", format="%(levelname)s:%(name)s:%(lineno)d:%(message)s"
)
logger = logging.getLogger(__name__)
def generate_dockerfiles():
for base_image in BASE_IMAGES:
for python_version in PYTHON_VERSIONS:
with open(Path.cwd() / "templates" / f"{base_image}.j2", "r") as f:
logger.info(
"Generating Dockerfile for "
f"{base_image}:{python_version}:{POETRY_VERSION}"
)
template = Template(f.read()).render(
python_version=python_version, poetry_version=POETRY_VERSION
)
output_file = Path(
Path.cwd() / "docker" / base_image / python_version / "Dockerfile"
)
output_file.parent.mkdir(exist_ok=True, parents=True)
with open(output_file, "w") as f:
f.write(f"{template}\n")
if __name__ == "__main__":
generate_dockerfiles()