-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRakefile
More file actions
69 lines (58 loc) · 1.7 KB
/
Rakefile
File metadata and controls
69 lines (58 loc) · 1.7 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
63
64
65
66
67
68
69
@docker_image_name = 'rubydata/rubykaigi2018'
namespace :docker do
desc "Build docker image"
task :build do
Dir.chdir File.expand_path('../docker', __FILE__) do
no_cache = ['--no-cache'] if ENV['no_cache']
sh 'docker', 'build', *no_cache, '-t', "#{@docker_image_name}:latest", '.'
end
end
desc "Push docker image"
task :push do
Dir.chdir File.expand_path('../docker', __FILE__) do
sh 'docker', 'push', "#{@docker_image_name}:latest"
end
end
desc "Pull docker image"
task :pull do
sh 'docker', 'pull', @docker_image_name
end
namespace :run do
def normalize_volume(volume)
local, remote = volume.split(':', 2)
"#{File.expand_path(local)}:#{remote}"
end
def docker_run(*args)
port = ['-p', "#{ENV['port']}:#{ENV['port']}"] if ENV['port']
volume = ['-v', normalize_volume(ENV['volume'])] if ENV['volume']
system 'docker', 'run', '--rm', '-it', *port, *volume,
@docker_image_name, *args
end
def docker_run_jupyter(app)
ENV['port'] ||= '8888'
case app
when :notebook
ENV['ENABLE_JUPYTER_LAB'] = nil
when :lab
ENV['ENABLE_JUPYTER_LAB'] = '1'
end
docker_run("start-notebook.sh",
"--port=#{ENV['port']}",
"--NotebookApp.token=rubykaigi2018"
)
end
desc "Run jupyter notebook on docker"
task :notebook do
docker_run_jupyter :notebook
end
desc "Run jupyter notebook on docker"
task :lab do
ENV['JUPYTER_ENABLE_LAB'] = '1'
docker_run_jupyter :lab
end
desc "Run jupyter notebook on docker"
task :bash do
docker_run("start.sh", "/bin/bash")
end
end
end