-
-
Notifications
You must be signed in to change notification settings - Fork 86
/
buildDocker.py
45 lines (37 loc) · 1.71 KB
/
buildDocker.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
import os, argparse
def main():
parser = argparse.ArgumentParser(description="run docker in any os")
parser.add_argument("-dev", "--developer", action="store_true", help="ssh inside docker container without running make")
args = parser.parse_args()
if args.developer:
# Mac and Linux
if os.name == "posix":
try:
os.system('systemctl start docker')
except:
os.system('systemctl unmask docker.service && systemctl unmask docker.socket && systemctl start docker.service')
os.system('sudo docker build -t dnnc .')
os.system('sudo docker run -it dnnc /bin/bash')
# Windows
elif os.name == "nt":
os.system('docker build -t dnnc .')
# don't use single quotes inside command, always use duble quotes, similar problem listed below
# https://stackoverflow.com/questions/24673698/unexpected-eof-while-looking-for-matching-while-using-sed
os.system('docker run -it dnnc /bin/bash -c "cd /dnnCompiler && make clean && make all"')
else:
# Mac and Linux
if os.name == "posix":
try:
os.system('systemctl start docker')
except:
os.system('systemctl unmask docker.service && systemctl unmask docker.socket && systemctl start docker.service')
os.system('sudo docker build -t dnnc .')
os.system('sudo docker run -it dnnc /bin/bash -c "cd /dnnCompiler && make clean && make all"')
# Windows
elif os.name == "nt":
os.system('docker build -t dnnc .')
# don't use single quotes inside command, always use duble quotes, similar problem listed below
# https://stackoverflow.com/questions/24673698/unexpected-eof-while-looking-for-matching-while-using-sed
os.system('docker run -it dnnc /bin/bash -c "cd /dnnCompiler && make clean && make all"')
if __name__ == "__main__":
main()