forked from RubyData/workshop_taiwan_201804
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
46 lines (41 loc) · 1.36 KB
/
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
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', 'rubydata/taiwan201804:latest', '.'
end
end
desc "Push docker image"
task :push do
Dir.chdir File.expand_path('../docker', __FILE__) do
sh 'docker', 'push', 'rubydata/taiwan201804:latest'
end
end
desc "Pull docker image"
task :pull do
sh 'docker', 'pull', 'rubydata/taiwan201804'
end
namespace :run do
def normalize_volume(volume)
local, remote = volume.split(':', 2)
"#{File.expand_path(local)}:#{remote}"
end
desc "Run jupyter notebook on docker"
task :notebook do
port = ENV['port'] || 8888
volume = ['-v', normalize_volume(ENV['volume'])] if ENV['volume']
sh 'docker', 'run', '--rm', '-it', '-p', "#{port}:#{port}", *volume,
'rubydata/taiwan201804',
'/usr/local/bin/start-taiwan2018.sh', "--port=#{port}"
end
desc "Run jupyter notebook on docker"
task :bash do
port = ENV['port'] || '8888'
port = port.empty? ? [] : ['-p', "#{port}:#{port}"]
volume = ['-v', normalize_volume(ENV['volume'])] if ENV['volume']
sh 'docker', 'run', '--rm', '-it', *port, *volume,
'rubydata/taiwan201804', '/bin/bash'
end
end
end