torquay 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/torquay.rb +58 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8792d5f5749783bc075a296e8f9b855ac06e0e38
|
4
|
+
data.tar.gz: 8839bac7410282179ad22118d32c31447438eb71
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e303f7fe464fe991586776cb816bebdd73bc4a2636999d70c4f63b4f942223c44dfc995c23a191cb87b02f5f53fdd13df2e498636e9f352a4dfdfbe4a94b9fc8
|
7
|
+
data.tar.gz: 5b25a6c3275314392661f5b2d08016a8f338ddc95358677596f84551108cbb93567a1f05194697def7c843e6e72849cbe64cc291f83c1e820b20d8f3c86f5597
|
data/lib/torquay.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
class Torquay
|
2
|
+
def initialize
|
3
|
+
require 'docker'
|
4
|
+
Docker.options = { :write_timeout => 300, :read_timeout => 300 }
|
5
|
+
Docker.validate_version!
|
6
|
+
@host = {
|
7
|
+
:host_ip => get_host_ip,
|
8
|
+
:ports => {}
|
9
|
+
}
|
10
|
+
@container = nil
|
11
|
+
@image = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_host_ip
|
15
|
+
# Let the crazy one-liner definition begin:
|
16
|
+
# Docker.url.split(':')[1][2..-1]
|
17
|
+
# Docker.url = tcp://192.168.123.205:2375
|
18
|
+
# split(':') = ["tcp", "//192.168.123.205", "2375"]
|
19
|
+
# [1] = "//192.168.123.205"
|
20
|
+
# [2..-1] = "192.168.123.205"
|
21
|
+
# This last bit prunes the leading //
|
22
|
+
url = Docker.url
|
23
|
+
case url.split(':')[0]
|
24
|
+
when 'unix'
|
25
|
+
ip = "127.0.0.1"
|
26
|
+
when 'tcp'
|
27
|
+
ip = url.split(':')[1][2..-1]
|
28
|
+
end
|
29
|
+
ip
|
30
|
+
end
|
31
|
+
|
32
|
+
def provision(name, dockerfile_path)
|
33
|
+
dockerfile = IO.read(dockerfile_path)
|
34
|
+
@image = Docker::Image.build(dockerfile)
|
35
|
+
@container = Docker::Container.create({
|
36
|
+
'Image' => @image.id,
|
37
|
+
'Hostname' => "#{name}-#{image.id}",
|
38
|
+
})
|
39
|
+
|
40
|
+
@container.start({"PublishAllPorts" => true, "CapAdd" => "NET_ADMIN"})
|
41
|
+
@host[:ports] = @container.json["NetworkSettings"]["Ports"]
|
42
|
+
end
|
43
|
+
|
44
|
+
def cleanup
|
45
|
+
if @container
|
46
|
+
@container.stop
|
47
|
+
@container.delete
|
48
|
+
end
|
49
|
+
if @image
|
50
|
+
@image.remove(:force => true)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
attr_reader :host
|
55
|
+
attr_reader :container
|
56
|
+
attr_reader :image
|
57
|
+
end
|
58
|
+
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: torquay
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tal Levy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: docker-api
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.21'
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '1.21'
|
25
|
+
prerelease: false
|
26
|
+
type: :runtime
|
27
|
+
description: Utility class for managing Docker containers and images, wrapping docker-api
|
28
|
+
email: tal@elastic.co
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/torquay.rb
|
34
|
+
homepage: https://github.com/talevy/docker-doctor
|
35
|
+
licenses:
|
36
|
+
- apache-2.0
|
37
|
+
metadata: {}
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 2.4.5
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: Wrapper utility functions around Docker image creation and maintenance
|
58
|
+
test_files: []
|
59
|
+
has_rdoc:
|