forked from upserve/docker-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
43 lines (36 loc) · 1004 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
# frozen_string_literal: true
require 'bundler/setup'
ENV['PATH'] = "/opt/docker/:#{ENV['PATH']}" if ENV['CI'] == 'true'
require 'docker'
require 'rspec/core/rake_task'
desc 'Run the full test suite from scratch'
task :default => [:unpack, :rspec]
RSpec::Core::RakeTask.new do |t|
t.pattern = 'spec/**/*_spec.rb'
end
desc 'Download the necessary base images'
task :unpack do
%w( swipely/base registry busybox:uclibc tianon/true debian:stable ).each do |image|
system "docker pull #{image}"
end
end
desc 'Run spec tests with a registry'
task :rspec do
begin
registry = Docker::Container.create(
'name' => 'registry',
'Image' => 'registry',
'Env' => ["GUNICORN_OPTS=[--preload]"],
'ExposedPorts' => {
'5000/tcp' => {}
},
'HostConfig' => {
'PortBindings' => { '5000/tcp' => [{ 'HostPort' => '5000' }] }
}
)
registry.start
Rake::Task["spec"].invoke
ensure
registry.kill!.remove unless registry.nil?
end
end