-
Notifications
You must be signed in to change notification settings - Fork 40
/
update.py
26 lines (19 loc) · 903 Bytes
/
update.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
import os
import re
import shutil
import subprocess
# versions will be a list of all #, ## and ##.## directories
versions = [p for p in os.listdir() if os.path.isdir(p) and re.match(r"^\d+(\.\d+)?$", p)]
with open(os.path.join("template", "Dockerfile.template"), "r", encoding="utf-8") as f:
dockerfile_template = f.read()
for version in versions:
# write Dockerfile in version directory
with open(os.path.join(version, "Dockerfile"), "w", encoding="utf-8") as f:
f.write(dockerfile_template % {"VERSION":version})
# copy other files into version directory
for file_name in os.listdir("template"):
if file_name == "Dockerfile.template":
continue
# we use system cp in order to preserve file permissions
p = subprocess.Popen(['cp', os.path.join("template", file_name), os.path.join(version, file_name)])
p.wait()