docker-builder 0.1.34 → 0.1.37

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14f1c7d7ca377f0eb931226a79fb56e29c3ca6ef
4
- data.tar.gz: 26794a1d0cef7af4b351be358e78e77d4ad2800c
3
+ metadata.gz: 2255579f59a5cfe1a5e1d927c00aee8b7f1202b9
4
+ data.tar.gz: 0dfee3c6a95987db55800c0228d71febf642afda
5
5
  SHA512:
6
- metadata.gz: f8638d3631950819b5b27a9c7f6aa186e1d59bac1a7b63b5b85653f35df41afa5ba782f1ee83a560f0479e931be519ded6860bf752ce6e28c1864d5b5505d3dc
7
- data.tar.gz: 035d9f135523e511775449d90e6b080727222b7eef2c5efd18fa971c2c1f746eedbdde50ee2d32e4e32d3cf451a320f628c31eb3464cc45d6e5b6549f1957a18
6
+ metadata.gz: fe2cbc5967ce7caf926dcf6cad392046152951cf5f5d04592c5def566c4f3bd3a96e557ba96cabdd70e2f209bd02e9f20ba5bfa30e729987cfb820f00c96c9b7
7
+ data.tar.gz: 4e68e3eba7c39406cadfc2df886507c826dd603335940a4778267934dfc1ad8cf58207e9f7a923dfdbda465ff11f5b1c1568d0574730470c6a8252b9d6e32500
data/install_local.sh CHANGED
@@ -1,2 +1,2 @@
1
1
  gem build docker-builder.gemspec
2
- gem install ./docker-builder-0.1.34.gem
2
+ gem install ./docker-builder-0.1.37.gem
@@ -232,10 +232,10 @@ class Manager
232
232
 
233
233
 
234
234
  def self.wait_until_running(container_name)
235
- retries = 20
235
+ retries = 10
236
236
  until system("docker exec #{container_name} true") || retries < 0
237
- sleep 0.5
238
- retries == retries - 1
237
+ sleep 1
238
+ retries = retries - 1
239
239
  end
240
240
 
241
241
  assert_container_running(container_name)
@@ -1,20 +1,20 @@
1
1
  module DockerBuilder
2
2
 
3
3
  class ServerSettings
4
- attr_accessor :attributes
4
+ attr_accessor :properties
5
5
 
6
6
  def get_binding
7
7
  return binding()
8
8
  end
9
9
 
10
- def attributes
11
- @attributes ||= {}
12
- @attributes
10
+ def properties
11
+ @properties ||= {}
12
+ @properties
13
13
  end
14
14
 
15
15
 
16
16
  def all_attributes
17
- res = attributes
17
+ res = properties
18
18
 
19
19
  res['base'] = {
20
20
  'image_name'=> image_name,
@@ -33,7 +33,7 @@ class ServerSettings
33
33
 
34
34
  #
35
35
  def node
36
- res = attributes['attributes'] || {}
36
+ res = properties['attributes'] || {}
37
37
 
38
38
  res['name'] = name
39
39
  res['container_name'] = container_name
@@ -41,61 +41,99 @@ class ServerSettings
41
41
  res
42
42
  end
43
43
 
44
- #
44
+ ### DSL
45
45
  def set(name, v)
46
- attributes[name] = v
46
+ properties[name] = v
47
47
  end
48
48
 
49
49
  def add(name, v)
50
- attributes[name] = {} if attributes[name].nil?
50
+ properties[name] = {} if properties[name].nil?
51
+
52
+ properties[name].merge!(v)
53
+ end
54
+
55
+
56
+ def add_config(a)
57
+ # merge
58
+ build(a['build']) if a['build']
59
+ provision(a['provision']) if a['provision']
60
+ docker(a['docker']) if a['docker']
61
+ attributes(a['attributes']) if a['attributes']
62
+
63
+
64
+ end
65
+
66
+ def build(v)
67
+ properties['build'] = v
68
+ end
51
69
 
52
- attributes[name].merge!(v)
70
+ def provision(v)
71
+ properties['provision'] = v
53
72
  end
54
73
 
74
+ def docker(a)
75
+ # merge
76
+ properties['docker'] ||= {}
77
+
78
+ a.each do |k,v|
79
+ properties['docker'][k] = v
80
+ end
81
+ end
82
+
83
+ def attributes(a)
84
+ # merge
85
+ properties['attributes'] ||= {}
86
+
87
+ a.each do |k,v|
88
+ properties['attributes'][k] = v
89
+ end
90
+ end
91
+
92
+
55
93
  ###
56
94
  def prefix
57
- attributes['common']['prefix']
95
+ properties['common']['prefix']
58
96
  end
59
97
 
60
98
  def container_prefix
61
- "#{attributes['common']['prefix']}#{attributes['common']['container_prefix']}"
99
+ "#{properties['common']['prefix']}#{properties['common']['container_prefix']}"
62
100
  end
63
101
 
64
102
  def image_prefix
65
- "#{attributes['common']['prefix']}#{attributes['common']['image_prefix']}"
103
+ "#{properties['common']['prefix']}#{properties['common']['image_prefix']}"
66
104
  end
67
105
 
68
106
  def service_prefix
69
- "#{attributes['common']['prefix']}#{attributes['common']['service_prefix']}"
107
+ "#{properties['common']['prefix']}#{properties['common']['service_prefix']}"
70
108
  end
71
109
 
72
110
 
73
111
  ###
74
112
 
75
113
  def name
76
- attributes['name']
114
+ properties['name']
77
115
  end
78
116
 
79
117
 
80
118
 
81
119
  def image_name
82
120
  if !need_build?
83
- bi = attributes['build']['base_image']
121
+ bi = properties['build']['base_image']
84
122
  return "#{bi['name']}:#{bi['tag']}"
85
123
  end
86
124
 
87
125
  #
88
- s = attributes['name']
126
+ s = properties['name']
89
127
 
90
- if attributes['build']['image_name']
91
- s = "#{attributes['build']['image_name']}"
128
+ if properties['build']['image_name']
129
+ s = "#{properties['build']['image_name']}"
92
130
  end
93
131
 
94
132
  "#{image_prefix}#{s}"
95
133
  end
96
134
 
97
135
  def need_build?
98
- build_type = attributes['build']['build_type']
136
+ build_type = properties['build']['build_type']
99
137
  return false if build_type=='' || build_type=='none'
100
138
 
101
139
 
@@ -103,7 +141,7 @@ class ServerSettings
103
141
  end
104
142
 
105
143
  def container_name(name=nil)
106
- name ||= attributes['name']
144
+ name ||= properties['name']
107
145
  s = name
108
146
 
109
147
  "#{container_prefix}#{s}"
@@ -122,7 +160,7 @@ class ServerSettings
122
160
  res = "$PWD/servers/#{self.name}/#{s}"
123
161
 
124
162
  elsif v =~ /^\/\//
125
- res = self.attributes['common']['dir_data']+(v.gsub /^\/\//, '')
163
+ res = self.properties['common']['dir_data']+(v.gsub /^\/\//, '')
126
164
  elsif v =~ /^\//
127
165
  res = v
128
166
  else
@@ -133,14 +171,14 @@ class ServerSettings
133
171
  end
134
172
 
135
173
  def dir_data
136
- "#{attributes['common']['dir_data']}#{self.name}/"
174
+ "#{properties['common']['dir_data']}#{self.name}/"
137
175
  end
138
176
 
139
177
 
140
178
  ### docker swarm services
141
179
 
142
180
  def service_name(name=nil)
143
- name ||= attributes['name']
181
+ name ||= properties['name']
144
182
  s = name
145
183
 
146
184
  "#{service_prefix}#{s}"
@@ -148,7 +186,7 @@ class ServerSettings
148
186
 
149
187
  ###
150
188
  def docker_volumes
151
- a = attributes['docker']['volumes'] || []
189
+ a = properties['docker']['volumes'] || []
152
190
 
153
191
  # fix paths
154
192
  res = a.map do |r|
@@ -171,7 +209,7 @@ class ServerSettings
171
209
  ###
172
210
 
173
211
  def docker_volumes_from
174
- a = attributes['docker']['volumes_from'] || []
212
+ a = properties['docker']['volumes_from'] || []
175
213
 
176
214
  # fix paths
177
215
  res = a.map do |r|
@@ -191,7 +229,7 @@ class ServerSettings
191
229
 
192
230
  ###
193
231
  def docker_ports
194
- a = attributes['docker']['ports'] || []
232
+ a = properties['docker']['ports'] || []
195
233
  a
196
234
  end
197
235
 
@@ -205,7 +243,7 @@ class ServerSettings
205
243
 
206
244
  ###
207
245
  def docker_links
208
- a = attributes['docker']['links'] || []
246
+ a = properties['docker']['links'] || []
209
247
 
210
248
  # fix
211
249
  res = a.map do |r|
@@ -226,7 +264,7 @@ class ServerSettings
226
264
  ###
227
265
 
228
266
  def run_env_variables
229
- a = attributes['docker']['run_env'] || []
267
+ a = properties['docker']['run_env'] || []
230
268
 
231
269
  a
232
270
  end
@@ -239,21 +277,21 @@ class ServerSettings
239
277
  ###
240
278
 
241
279
  def run_extra_options_string
242
- s = attributes['docker']['run_extra_options'] || ''
280
+ s = properties['docker']['run_extra_options'] || ''
243
281
  s
244
282
  end
245
283
 
246
284
 
247
285
  ###
248
286
  def is_swarm_mode?
249
- v = attributes["docker"]["swarm_mode"]
287
+ v = properties["docker"]["swarm_mode"]
250
288
  return false if v.nil?
251
289
  return v
252
290
  end
253
291
 
254
292
  ###
255
293
  def [](key)
256
- attributes[key]
294
+ properties[key]
257
295
  end
258
296
 
259
297
 
@@ -302,7 +340,7 @@ class Settings
302
340
 
303
341
  # set from main Config
304
342
  Config.servers[name].each do |k,v|
305
- settings.attributes[k]=v
343
+ settings.properties[k]=v
306
344
  end
307
345
 
308
346
 
@@ -321,10 +359,10 @@ class Settings
321
359
  eval(t, settings.get_binding)
322
360
 
323
361
  #
324
- settings.attributes['name'] ||= name
362
+ settings.properties['name'] ||= name
325
363
 
326
364
  # from common config
327
- settings.attributes['common'] = Config.options[:common]
365
+ settings.properties['common'] = Config.options[:common]
328
366
 
329
367
  settings
330
368
  end
@@ -1,3 +1,3 @@
1
1
  module DockerBuilder
2
- VERSION = "0.1.34"
2
+ VERSION = "0.1.37"
3
3
  end
data/readme.md CHANGED
@@ -362,6 +362,8 @@ Run from outside container
362
362
 
363
363
  ```
364
364
 
365
+ it will run script `name=myserver ruby myprovision1.rb` from the host machine.
366
+
365
367
 
366
368
  ## Development
367
369
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.34
4
+ version: 0.1.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Ivak
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-22 00:00:00.000000000 Z
11
+ date: 2017-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler