-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
48 lines (39 loc) · 1.08 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
47
48
require 'rubygems'
require 'bundler/setup'
require 'docker'
require 'fileutils'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
RuboCop::RakeTask.new
RSpec::Core::RakeTask.new(:spec)
desc 'Run dockerfile_lint'
task :lint do
proj_root = File.dirname(__FILE__)
FileList['**/Dockerfile'].exclude(/^vendor/).each do |dockerfile|
puts "---> lint:#{dockerfile}"
image = Docker::Image.create('fromImage' => 'projectatomic/dockerfile-lint', 'tag' => 'latest')
container = Docker::Container.create({
:Cmd => [ 'dockerfile_lint', '-r', '.dockerfile_lint.yml', '-f', dockerfile ],
:Image => image.id,
:HostConfig => {
:Binds => ["#{proj_root}:/root"],
:Privileged => true,
},
:Tty => true,
:Volumes => { '/root' => {} },
})
container.start
status_code = container.wait['StatusCode']
puts container.logs(stdout: true)
container.remove
if status_code.nonzero?
exit status_code
end
end
end
desc 'Run lint, rubocop, and spec'
task :test => [
:lint,
:rubocop,
:spec,
]