-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathin-docker
executable file
·55 lines (51 loc) · 2.06 KB
/
in-docker
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
52
53
54
55
#!/usr/bin/env python3
import sys
from argparse import ArgumentParser
import os
import subprocess
def main():
parser = ArgumentParser()
parser.add_argument("--arch", default="x86_64")
parser.add_argument("--python-version", default="cp36-cp36m")
parser.add_argument("--version", default="2025-02-01-f4d91ceac")
args, rest = parser.parse_known_args()
if rest[:1] == ["--"]:
del rest[0]
basedir = os.path.dirname(os.path.realpath(__file__))
local_build = os.path.join(basedir, "build.docker")
container_build = os.path.join(basedir, "build")
os.makedirs(local_build, exist_ok=True)
# Create directory at container path as well, otherwise docker will create
# it for us with root:root ownership.
os.makedirs(container_build, exist_ok=True)
local_ccache = os.path.expanduser("~/.ccache")
container_ccache = "/var/cache/ccache"
os.makedirs(local_ccache, exist_ok=True)
local_pip_cache = os.path.expanduser("~/.cache/pip")
container_pip_cache = "/var/cache/pip"
os.makedirs(local_pip_cache, exist_ok=True)
local_skbuild = os.path.join(basedir, "_skbuild.docker")
container_skbuild = os.path.join(basedir, "_skbuild")
os.makedirs(local_skbuild, exist_ok=True)
os.makedirs(container_skbuild, exist_ok=True)
docker_run_args = [
"docker",
"run",
f"--env=CCACHE_DIR={container_ccache}",
f"--env=PIP_CACHE_DIR={container_pip_cache}",
"--interactive",
"--rm",
*(("--tty",) if os.isatty(sys.stdin.fileno()) else ()),
f"--user={os.getuid()}:{os.getgid()}",
f"--volume={basedir}:{basedir}:z",
f"--volume={local_build}:{container_build}:z",
f"--volume={local_ccache}:{container_ccache}:z",
f"--volume={local_pip_cache}:{container_pip_cache}:z",
f"--volume={local_skbuild}:{container_skbuild}:z",
f"--workdir={basedir}",
f"mephi42/memtrace-build-{args.arch}-{args.python_version}:{args.version}",
*rest,
]
subprocess.check_call(docker_run_args)
if __name__ == "__main__":
main()