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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -2
  3. data/Gemfile.lock +12 -4
  4. data/lib/docker_process.rb +30 -16
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a87ca2bb5b3f17eb380bcca03ffa348017631545
4
- data.tar.gz: a59b2d9d472370b981e730b1fe03708a7522f52a
3
+ metadata.gz: 8db02889653aec64f9c6491d76f9898eefed4e34
4
+ data.tar.gz: a624fa913415a129c2a518e7e837e385ea95df33
5
5
  SHA512:
6
- metadata.gz: 298694936a84e887f3a882521151e8d24a2e4fbfcfb220d5044a7d898c91a0d958e25a97401fd23c1d5579351336b92098efdaa0b812f438068f7775e8a82b32
7
- data.tar.gz: 0331af2dc162d1a3f5b0ac7f13c0264d8d36186d6c0f227bab0438a7cec45d238ed798e76d37bf58baa0acd08d805bf66395ec3c2d69142a041de18bae972566
6
+ metadata.gz: 4108a899a8db1eb3c4aa6adafa0d49b1802807119234be0ad9df52260af059dfcc609db3c2b5d0da70fb618394301b8a37bca2c597a7afaa247111baec577dc8
7
+ data.tar.gz: 45e1e4791d134af95bc0354ed5553a3d5620e43672b624a8e341c63a788d552ef1c59f17be942b1a9b75cd70887bc8326cbf4cd6626cdfb037117fbb235a8099
data/Gemfile CHANGED
@@ -1,2 +1 @@
1
- source 'https://rubygems.org'
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
- backticks (0.5.0)
5
- docker (0.3.1)
6
- backticks (~> 0.3)
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
- docker
20
+ docker_process!
13
21
 
14
22
  BUNDLED WITH
15
23
  1.12.5
@@ -6,25 +6,36 @@ require 'docker'
6
6
 
7
7
  class DockerProcess
8
8
 
9
- @@image_name = nil
10
- @@properties = []
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
- @@image_name = name
18
+ @image_name = name
19
+ end
20
+
21
+ def self.properties
22
+ @properties
14
23
  end
15
24
 
16
- def self.set_properties *properties
17
- raise 'can not reset properties' if !@@properties.empty?
18
- @@properties.map(&:to_sym).each do |property|
19
- @@properties << property
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 @@image_name.nil?
27
- raise 'properties not set' if @@properties.empty?
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' => @@image_name)
66
- log "creating container [#{@@image_name}] => #{self.config} with env #{env_vars}"
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
- log "already running, not starting"
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
- log "created container: #{container.id}"
78
- log "starting container"
91
+ puts "created container: #{container.id}"
92
+ puts "starting container"
79
93
  container.start
80
- log "container started"
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.1
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
  - - ">="