-
Notifications
You must be signed in to change notification settings - Fork 9
/
build_images.py
executable file
·51 lines (43 loc) · 2.01 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
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python2
# Copyright (c) 2015 GeometryFactory (France). All rights reserved.
# All rights reserved.
#
# This file is part of CGAL (www.cgal.org).
# You can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
#
# Licensees holding a valid commercial license may use this file in
# accordance with the commercial license agreement provided with the software.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
# WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# Author(s) : Philipp Moeller
import docker
import argparse
import os
def main():
parser = argparse.ArgumentParser(
description='This script launches build the cgal-testsuite images.'
' Unless any directories are specified this will process all immediate child directories'
' of the current working directory that contain a Dockerfile.')
parser.add_argument('dirs', metavar='DIRNAME', nargs='*',
help='Directory to process.')
parser.add_argument('--docker-url', metavar='protocol://hostname/to/docker.sock[:PORT]',
default='unix://var/run/docker.sock',
help='The protocol+hostname+port where the Docker server is hosted.')
args = parser.parse_args()
client = docker.Client(base_url=args.docker_url)
if not args.dirs:
fullnames = (os.path.join(os.getcwd(), name) for name in os.listdir(os.getcwd()))
args.dirs = [name for name in fullnames if os.path.isfile(os.path.join(name, 'Dockerfile'))]
print(args.dirs)
for d in args.dirs:
tag = 'cgal-testsuite/' + os.path.basename(d).lower()
print('Building directory {} with tag {}'.format(d, tag))
response = client.build(path=d, rm=True, tag=tag, stream=False)
for l in response:
print(l)
if __name__ == "__main__":
main()