forked from OSC/ood-documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
62 lines (51 loc) · 1.14 KB
/
Rakefile
File metadata and controls
62 lines (51 loc) · 1.14 KB
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
56
57
58
59
60
61
62
task :default do
system "rake --tasks"
end
desc "Build docs using docker"
task :build do
cmd = "#{run_cmd} make html"
puts cmd
exec cmd
end
desc "Spellcheck"
task :spellcheck do
exec "#{run_cmd} make spellcheck"
end
desc "Open built documentation in browser"
task :open do
if windows?
system 'start .\build\html\index.html'
else
exec '(command -v xdg-open >/dev/null 2>&1 && xdg-open build/html/index.html) || open build/html/index.html'
end
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?
exists? 'docker'
end
def podman?
exists? 'podman'
end
def exists?(program)
`#{program} -v 2>/dev/null 2>&1`
$?.success?
end
def windows?
Gem.win_platform?
end
def run_cmd
if podman?
"podman run --rm -it -v #{__dir__}:/doc #{image}"
elsif docker?
user_section = windows? ? nil : "-u '#{user_group}'"
"docker run --rm -it -v \"#{__dir__}:/doc\" #{user_section} #{image}"
else
raise StandardError, "Cannot find any suitable container runtime to build. Need 'podman' or 'docker' installed."
end
end