-
Notifications
You must be signed in to change notification settings - Fork 6
/
build-images.py
39 lines (28 loc) · 1.28 KB
/
build-images.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
import colorama, subprocess, sys, tempfile
from termcolor import colored
# The Windows releases we build images for
RELEASES = ['1809', '2004', '20H2']
# The alias tags we create for convenience purposes
ALIASES = {'ltsc2019': '1809'}
# Prints and runs a command
def run(command, **kwargs):
print(colored(command, color='yellow'))
result = subprocess.run(command, check=True, **kwargs)
print('', flush=True)
return result
# Initialise colour output
colorama.init()
# Build the default image for each supported Windows release
for release in RELEASES:
# Create a temporary directory to hold the Dockerfile
with tempfile.TemporaryDirectory() as tempDir:
# Generate the Dockerfile and build the image
run(['dlldiag', 'docker', 'Dockerfile', 'mcr.microsoft.com/windows/servercore:{}'.format(release)], cwd=tempDir)
run(['docker', 'build', '-t', 'adamrehn/dll-diagnostics:{}'.format(release), tempDir])
# Create our alias tags
for alias, target in ALIASES.items():
run(['docker', 'tag', 'adamrehn/dll-diagnostics:{}'.format(target), 'adamrehn/dll-diagnostics:{}'.format(alias)])
# Push the images to Docker Hub if requested
if len(sys.argv) > 1 and sys.argv[1] == '--push':
for tag in RELEASES + list(ALIASES.keys()):
run(['docker', 'push', 'adamrehn/dll-diagnostics:{}'.format(tag)])