-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathRakefile
48 lines (39 loc) · 959 Bytes
/
Rakefile
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
task :default do
system "rake --tasks"
end
desc "Build docs using docker"
task :build do
exec "#{run_cmd} make html"
end
desc "Spellcheck"
task :spellcheck do
exec "#{run_cmd} make spellcheck"
end
desc "Open built documentation in browser"
task :open do
exec '(command -v xdg-open >/dev/null 2>&1 && xdg-open build/html/index.html) || open build/html/index.html'
end
def user_group
pwnam = Etc.getpwnam(Etc.getlogin)
"#{pwnam.uid}:#{pwnam.gid}"
end
def image
'ohiosupercomputer/ood-doc-build:v3.1.0'
end
def docker?
`which docker 2>/dev/null 2>&1`
$?.success?
end
def podman?
`which podman 2>/dev/null 2>&1`
$?.success?
end
def run_cmd
if podman?
"podman run --rm -it -v #{__dir__}:/doc #{image}"
elsif docker?
"docker run --rm -it -v '#{__dir__}:/doc' -u '#{user_group}' #{image}"
else
raise StandardError, "Cannot find any suitable container runtime to build. Need 'podman' or 'docker' installed."
end
end