File: Rakefile

package info (click to toggle)
ruby-docker-api 2.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 432 kB
  • sloc: ruby: 4,044; sh: 138; makefile: 5
file content (54 lines) | stat: -rw-r--r-- 1,285 bytes parent folder | download | duplicates (2)
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
require 'bundler/setup'

ENV['PATH'] = "/opt/docker/:#{ENV['PATH']}" if ENV['CI'] == 'true'

require 'docker'
require 'rspec/core/rake_task'
require 'cane/rake_task'


desc 'Run the full test suite from scratch'
task :default => [:unpack, :rspec, :quality]

RSpec::Core::RakeTask.new do |t|
  t.pattern = 'spec/**/*_spec.rb'
end

Cane::RakeTask.new(:quality) do |cane|
  cane.canefile = '.cane'
end

desc 'Download the necessary base images'
task :unpack do
  %w( swipely/base registry busybox 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

desc 'Pull an Ubuntu image'
image 'ubuntu:13.10' do
  puts "Pulling ubuntu:13.10"
  image = Docker::Image.create('fromImage' => 'ubuntu', 'tag' => '13.10')
  puts "Pulled ubuntu:13.10, image id: #{image.id}"
end