docker_process 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/Gemfile.lock +12 -4
- data/lib/docker_process.rb +30 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8db02889653aec64f9c6491d76f9898eefed4e34
|
4
|
+
data.tar.gz: a624fa913415a129c2a518e7e837e385ea95df33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4108a899a8db1eb3c4aa6adafa0d49b1802807119234be0ad9df52260af059dfcc609db3c2b5d0da70fb618394301b8a37bca2c597a7afaa247111baec577dc8
|
7
|
+
data.tar.gz: 45e1e4791d134af95bc0354ed5553a3d5620e43672b624a8e341c63a788d552ef1c59f17be942b1a9b75cd70887bc8326cbf4cd6626cdfb037117fbb235a8099
|
data/Gemfile
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
gem 'docker'
|
1
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,23 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
docker_process (0.0.1)
|
5
|
+
docker-api
|
6
|
+
|
1
7
|
GEM
|
2
8
|
remote: https://rubygems.org/
|
3
9
|
specs:
|
4
|
-
|
5
|
-
|
6
|
-
|
10
|
+
docker-api (1.29.0)
|
11
|
+
excon (>= 0.38.0)
|
12
|
+
json
|
13
|
+
excon (0.51.0)
|
14
|
+
json (2.0.1)
|
7
15
|
|
8
16
|
PLATFORMS
|
9
17
|
ruby
|
10
18
|
|
11
19
|
DEPENDENCIES
|
12
|
-
|
20
|
+
docker_process!
|
13
21
|
|
14
22
|
BUNDLED WITH
|
15
23
|
1.12.5
|
data/lib/docker_process.rb
CHANGED
@@ -6,25 +6,36 @@ require 'docker'
|
|
6
6
|
|
7
7
|
class DockerProcess
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
# these need to be re-set in each child
|
10
|
+
@image_name = nil
|
11
|
+
@properties = nil
|
12
|
+
|
13
|
+
def self.image_name
|
14
|
+
@image_name
|
15
|
+
end
|
11
16
|
|
12
17
|
def self.set_image_name name
|
13
|
-
|
18
|
+
@image_name = name
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.properties
|
22
|
+
@properties
|
14
23
|
end
|
15
24
|
|
16
|
-
def self.set_properties *
|
17
|
-
|
18
|
-
|
19
|
-
|
25
|
+
def self.set_properties *new_properties
|
26
|
+
puts "setting properties: #{new_properties}"
|
27
|
+
@properties ||= []
|
28
|
+
raise 'can not reset properties' if !@properties.empty?
|
29
|
+
new_properties.map(&:to_sym).each do |property|
|
30
|
+
@properties << property
|
20
31
|
end
|
21
32
|
end
|
22
33
|
|
23
34
|
attr_reader :config
|
24
35
|
|
25
36
|
def initialize config
|
26
|
-
raise 'image not set' if
|
27
|
-
raise 'properties not set' if
|
37
|
+
raise 'image not set' if self.class.image_name.nil?
|
38
|
+
raise 'properties not set' if self.class.properties.empty?
|
28
39
|
@config = config
|
29
40
|
end
|
30
41
|
|
@@ -62,22 +73,25 @@ class DockerProcess
|
|
62
73
|
end
|
63
74
|
|
64
75
|
def start_container
|
65
|
-
image = Docker::Image.create('fromImage' =>
|
66
|
-
|
76
|
+
image = Docker::Image.create('fromImage' => self.class.image_name)
|
77
|
+
puts "creating container [#{self.class.image_name}] => #{self.config} with env #{env_vars}"
|
67
78
|
if is_running?
|
68
|
-
|
79
|
+
puts "already running, not starting"
|
69
80
|
return false
|
70
81
|
end
|
71
82
|
container = Docker::Container.create({
|
72
83
|
'RestartPolicy' => { 'Name': 'always' },
|
73
84
|
'Image' => image.id,
|
74
85
|
'Env' => env_vars,
|
75
|
-
'Labels' => labels
|
86
|
+
'Labels' => labels,
|
87
|
+
'HostConfig' => {
|
88
|
+
'PublishAllPorts' => true
|
89
|
+
}
|
76
90
|
})
|
77
|
-
|
78
|
-
|
91
|
+
puts "created container: #{container.id}"
|
92
|
+
puts "starting container"
|
79
93
|
container.start
|
80
|
-
|
94
|
+
puts "container started"
|
81
95
|
true
|
82
96
|
end
|
83
97
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker_process
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robby ranshous
|
@@ -11,7 +11,7 @@ cert_chain: []
|
|
11
11
|
date: 2016-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: docker
|
14
|
+
name: docker-api
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|