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 +4 -4
- data/install_local.sh +1 -1
- data/lib/docker_builder/manager.rb +3 -3
- data/lib/docker_builder/server_settings.rb +73 -35
- data/lib/docker_builder/version.rb +1 -1
- data/readme.md +2 -0
- 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: 2255579f59a5cfe1a5e1d927c00aee8b7f1202b9
|
4
|
+
data.tar.gz: 0dfee3c6a95987db55800c0228d71febf642afda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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 =
|
235
|
+
retries = 10
|
236
236
|
until system("docker exec #{container_name} true") || retries < 0
|
237
|
-
sleep
|
238
|
-
retries
|
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 :
|
4
|
+
attr_accessor :properties
|
5
5
|
|
6
6
|
def get_binding
|
7
7
|
return binding()
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
@
|
12
|
-
@
|
10
|
+
def properties
|
11
|
+
@properties ||= {}
|
12
|
+
@properties
|
13
13
|
end
|
14
14
|
|
15
15
|
|
16
16
|
def all_attributes
|
17
|
-
res =
|
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 =
|
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
|
-
|
46
|
+
properties[name] = v
|
47
47
|
end
|
48
48
|
|
49
49
|
def add(name, v)
|
50
|
-
|
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
|
-
|
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
|
-
|
95
|
+
properties['common']['prefix']
|
58
96
|
end
|
59
97
|
|
60
98
|
def container_prefix
|
61
|
-
"#{
|
99
|
+
"#{properties['common']['prefix']}#{properties['common']['container_prefix']}"
|
62
100
|
end
|
63
101
|
|
64
102
|
def image_prefix
|
65
|
-
"#{
|
103
|
+
"#{properties['common']['prefix']}#{properties['common']['image_prefix']}"
|
66
104
|
end
|
67
105
|
|
68
106
|
def service_prefix
|
69
|
-
"#{
|
107
|
+
"#{properties['common']['prefix']}#{properties['common']['service_prefix']}"
|
70
108
|
end
|
71
109
|
|
72
110
|
|
73
111
|
###
|
74
112
|
|
75
113
|
def name
|
76
|
-
|
114
|
+
properties['name']
|
77
115
|
end
|
78
116
|
|
79
117
|
|
80
118
|
|
81
119
|
def image_name
|
82
120
|
if !need_build?
|
83
|
-
bi =
|
121
|
+
bi = properties['build']['base_image']
|
84
122
|
return "#{bi['name']}:#{bi['tag']}"
|
85
123
|
end
|
86
124
|
|
87
125
|
#
|
88
|
-
s =
|
126
|
+
s = properties['name']
|
89
127
|
|
90
|
-
if
|
91
|
-
s = "#{
|
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 =
|
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 ||=
|
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.
|
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
|
-
"#{
|
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 ||=
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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 =
|
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
|
-
|
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.
|
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.
|
362
|
+
settings.properties['name'] ||= name
|
325
363
|
|
326
364
|
# from common config
|
327
|
-
settings.
|
365
|
+
settings.properties['common'] = Config.options[:common]
|
328
366
|
|
329
367
|
settings
|
330
368
|
end
|
data/readme.md
CHANGED
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.
|
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-
|
11
|
+
date: 2017-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|