-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·37 lines (32 loc) · 1.35 KB
/
build
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import platform
import os
import sys
abspath = os.path.abspath(sys.argv[0])
basename = os.path.basename(abspath)
dirname = os.path.dirname(abspath)
base_args = [
"docker", "--privileged",
"-e", "DISPLAY=" + os.environ["DISPLAY"],
"-h", platform.node(),
"-v", os.environ["XAUTHORITY"] + ":/home/steam/.Xauthority:ro",
"-v", "/dev/dri:/dev/dri",
"-v", "/dev/shm:/dev/shm",
"-v", "/etc/localtime:/etc/localtime:ro",
"-v", "/etc/machine-id:/etc/machine-id:ro",
"-v", os.environ["HOME"] + "/.pulse-cookie:/home/steam/.pulse-cookie",
"-v", os.environ["HOME"] + "/.config/pulse:/home/steam/.config/pulse",
"-v", "/run/user/" + str(os.getuid()) + "/pulse:/run/user/1000/pulse",
"-v", "/tmp/.X11-unix:/tmp/.X11-unix",
"-v", "/var/lib/dbus:/var/lib/dbus",
"-v", dirname + "/Steam:/home/steam/.local/share/Steam",
os.path.split(dirname)[-1]
]
args = {
"build": [base_args[0], "build", "-f", dirname + "/src/Dockerfile", "-t"] + [base_args[-1], dirname],
"run": [base_args[0], "run"] + (base_args[-1:] + sys.argv[1:] if len(sys.argv) > 1 else base_args[1:]),
"login": [base_args[0], "run", "-it"] + (base_args[-1:] + sys.argv[1:] if len(sys.argv) > 1 else base_args[1:] + ["bash", "--login", "-i"])
}
if __name__ == "__main__":
os.execvp(base_args[0], args[basename])