forked from pennchildlanglab/tljh-datascience
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtljh_neurodesk.py
42 lines (36 loc) · 1.42 KB
/
tljh_neurodesk.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
from tljh.hooks import hookimpl as hook
import os, shutil, subprocess
image = "vnmd/neurodesktop"
@hook
def tljh_post_install(): # Setup the neurodesk-notebook
os .system("sudo systemctl start docker\n" +
f"sudo docker pull {image}")
if os.path.isdir("/etc/apparmor.d"):
os.chdir(__import__("CVMFS").__path__[0])
shutil.copyfile("apparmor", "/etc/apparmor.d/CVMFS")
os.system(f"""sudo apparmor_parser -r /etc/apparmor.d/CVMFS
docker{ ' ' if subprocess.getoutput
("dpkg-query --showformat='${db:Status-Status}' -W docker-ce") == "installed"
else '-'
}compose up -d
""")
@hook
def tljh_extra_apt_packages(): return ["docker.io", "docker-compose"]
@hook
def tljh_extra_hub_pip_packages(): return ["dockerspawner", "jupyter_client"]
@hook
def tljh_custom_jupyterhub_config(c):
from jupyter_client.localinterfaces import public_ips
c.JupyterHub.hub_ip = public_ips()[0]
c.JupyterHub.spawner_class = "dockerspawner.DockerSpawner"
c.DockerSpawner.name_template = "{username}-{imagename}"
c.DockerSpawner.image = image
c.DockerSpawner.extra_host_config = {
"security_opt": ["apparmor=unconfined"],
"cap_add": ["SYS_ADMIN"]
}
c.DockerSpawner.extra_create_kwargs = {"user": "root"}
c.DockerSpawner.volumes = {
"{prefix}-{username}": "/home/jovyan",
"/cvmfs": "/cvmfs"
}