docker-builder 0.1.29 → 0.1.30
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/cli.rb +55 -0
- data/lib/docker_builder/manager.rb +56 -42
- data/lib/docker_builder/version.rb +1 -1
- data/readme.md +37 -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: 256e96eb177d0c4fd4fbc0f79a06d3ab615c3f16
|
4
|
+
data.tar.gz: 648599fd31fa6686b2b67c1d577c40896041873e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10f38caa907ddf6e402031bb37e0fbe644c1a70ac49eefcfc57225725425b81b9172cb7daaa036abfbcb4c856c2dcba95b578181db92d219730f4a6f4f76944f
|
7
|
+
data.tar.gz: ae32df32af0100d09903fb461b887af2d65a0b691976dbba273002a9e18be3cf7da8346383bd5252eb25b3be215e7518bf1b48f4d14f0f7ac3309810b9ab5483
|
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.30.gem
|
data/lib/docker_builder/cli.rb
CHANGED
@@ -217,6 +217,61 @@ class CLI < Thor
|
|
217
217
|
end
|
218
218
|
|
219
219
|
|
220
|
+
##
|
221
|
+
# [start]
|
222
|
+
#
|
223
|
+
#
|
224
|
+
desc 'start', 'Start Docker container'
|
225
|
+
|
226
|
+
long_desc <<-EOS.gsub(/^ +/, '')
|
227
|
+
Start Docker container.
|
228
|
+
EOS
|
229
|
+
|
230
|
+
method_option :server,
|
231
|
+
:aliases => ['-s', '--server'],
|
232
|
+
:required => false,
|
233
|
+
:type => :string,
|
234
|
+
:desc => "Server name"
|
235
|
+
|
236
|
+
method_option :root_path,
|
237
|
+
:aliases => '-r',
|
238
|
+
:type => :string,
|
239
|
+
:default => '',
|
240
|
+
:desc => 'Root path to base all relative path on.'
|
241
|
+
|
242
|
+
method_option :config_file,
|
243
|
+
:aliases => '-c',
|
244
|
+
:type => :string,
|
245
|
+
:default => 'config.rb',
|
246
|
+
:desc => 'Path to your config.rb file.'
|
247
|
+
|
248
|
+
def start
|
249
|
+
puts "starting..."
|
250
|
+
|
251
|
+
opts = options
|
252
|
+
|
253
|
+
warnings = false
|
254
|
+
errors = false
|
255
|
+
begin
|
256
|
+
Config.load(options)
|
257
|
+
|
258
|
+
Config.servers.each do |name, opts|
|
259
|
+
server_settings = Settings.load_settings_for_server(name)
|
260
|
+
|
261
|
+
Manager.start_container(name, server_settings)
|
262
|
+
end
|
263
|
+
|
264
|
+
rescue Exception => err
|
265
|
+
puts "exception: #{err.inspect}"
|
266
|
+
raise err
|
267
|
+
exit(3)
|
268
|
+
end
|
269
|
+
|
270
|
+
exit(errors ? 2 : 1) if errors || warnings
|
271
|
+
|
272
|
+
end
|
273
|
+
|
274
|
+
|
220
275
|
|
221
276
|
##
|
222
277
|
# [destroy]
|
@@ -148,43 +148,9 @@ class Manager
|
|
148
148
|
|
149
149
|
|
150
150
|
# start
|
151
|
-
start_container(settings)
|
151
|
+
start_container(name, settings)
|
152
152
|
|
153
153
|
|
154
|
-
# provision after start
|
155
|
-
install_node_script_type = (settings['install']['node']['script_type'] rescue nil)
|
156
|
-
install_bootstrap_script_type = (settings['install']['bootstrap']['script_type'] rescue nil)
|
157
|
-
|
158
|
-
if install_node_script_type && install_node_script_type=='chef_recipe'
|
159
|
-
# run container and provision with chef
|
160
|
-
#_run_container_chef(settings)
|
161
|
-
|
162
|
-
# ???
|
163
|
-
#_provision_container_chef_recipe(settings)
|
164
|
-
|
165
|
-
elsif install_node_script_type && install_node_script_type=='shell'
|
166
|
-
# docker run
|
167
|
-
#create_and_run_container(settings)
|
168
|
-
|
169
|
-
# provision with shell script
|
170
|
-
run_shell_script_in_container(settings, "install.sh")
|
171
|
-
|
172
|
-
else
|
173
|
-
# no script for provision
|
174
|
-
#_run_container_docker(settings)
|
175
|
-
|
176
|
-
# docker run
|
177
|
-
#create_and_run_container(settings)
|
178
|
-
|
179
|
-
end
|
180
|
-
|
181
|
-
# bootstrap
|
182
|
-
if install_bootstrap_script_type && install_bootstrap_script_type=='shell'
|
183
|
-
script = settings['install']['bootstrap']['script'] || '/opt/bootstrap/bootstrap.sh'
|
184
|
-
|
185
|
-
# bootstsrap with shell script
|
186
|
-
run_bootsrap_shell_script_in_container(settings, script)
|
187
|
-
end
|
188
154
|
|
189
155
|
|
190
156
|
true
|
@@ -205,22 +171,18 @@ class Manager
|
|
205
171
|
end
|
206
172
|
end
|
207
173
|
|
208
|
-
def self.start_container(settings)
|
174
|
+
def self.start_container(name, settings)
|
209
175
|
# start
|
210
176
|
cmd %Q(docker start #{settings.container_name})
|
211
177
|
|
212
178
|
# setup
|
213
179
|
setup_container_after_start(settings)
|
214
|
-
end
|
215
|
-
|
216
180
|
|
217
|
-
|
218
|
-
|
219
|
-
cmd %Q(docker exec #{settings.container_name} #{script_path} )
|
181
|
+
# provision after start
|
182
|
+
run_provision_after_start(settings)
|
220
183
|
end
|
221
184
|
|
222
185
|
|
223
|
-
|
224
186
|
def self.setup_container_after_start(settings)
|
225
187
|
# second network
|
226
188
|
network2 = settings['docker']['network_secondary']
|
@@ -230,6 +192,8 @@ class Manager
|
|
230
192
|
gateway = network2['gateway']
|
231
193
|
|
232
194
|
if gateway
|
195
|
+
puts "setup network gateway"
|
196
|
+
|
233
197
|
# fix default gateway
|
234
198
|
cmd %Q(docker exec #{settings.container_name} ip route change default via #{gateway} dev eth1)
|
235
199
|
end
|
@@ -245,6 +209,56 @@ class Manager
|
|
245
209
|
end
|
246
210
|
|
247
211
|
|
212
|
+
|
213
|
+
def self.run_provision_after_start(settings)
|
214
|
+
|
215
|
+
install_node_script_type = (settings['install']['node']['script_type'] rescue nil)
|
216
|
+
install_bootstrap_script = (settings['install']['bootstrap']['script'] rescue nil)
|
217
|
+
|
218
|
+
if install_node_script_type && install_node_script_type=='chef_recipe'
|
219
|
+
# run container and provision with chef
|
220
|
+
#_run_container_chef(settings)
|
221
|
+
|
222
|
+
# ???
|
223
|
+
#_provision_container_chef_recipe(settings)
|
224
|
+
|
225
|
+
elsif install_node_script_type && install_node_script_type=='shell'
|
226
|
+
# docker run
|
227
|
+
#create_and_run_container(settings)
|
228
|
+
|
229
|
+
# provision with shell script
|
230
|
+
run_shell_script_in_container(settings, "install.sh")
|
231
|
+
|
232
|
+
else
|
233
|
+
# no script for provision
|
234
|
+
#_run_container_docker(settings)
|
235
|
+
|
236
|
+
# docker run
|
237
|
+
#create_and_run_container(settings)
|
238
|
+
|
239
|
+
end
|
240
|
+
|
241
|
+
# bootstrap
|
242
|
+
if install_bootstrap_script
|
243
|
+
#script = settings['install']['bootstrap']['script'] || '/opt/bootstrap/bootstrap.sh'
|
244
|
+
|
245
|
+
# bootstsrap with shell script
|
246
|
+
run_bootsrap_shell_script_in_container(settings, install_bootstrap_script)
|
247
|
+
end
|
248
|
+
|
249
|
+
|
250
|
+
true
|
251
|
+
end
|
252
|
+
|
253
|
+
|
254
|
+
def self.run_bootsrap_shell_script_in_container(settings, script_path)
|
255
|
+
# exec
|
256
|
+
cmd %Q(docker exec #{settings.container_name} #{script_path} )
|
257
|
+
end
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
248
262
|
### systemd service
|
249
263
|
|
250
264
|
def self._install_service_container(settings)
|
data/readme.md
CHANGED
@@ -480,6 +480,18 @@ it will NOT build a new Docker image.
|
|
480
480
|
|
481
481
|
|
482
482
|
|
483
|
+
# Start Docker container
|
484
|
+
|
485
|
+
docker-builder start -s server_name
|
486
|
+
|
487
|
+
it starts docker container which was previously created.
|
488
|
+
|
489
|
+
Process:
|
490
|
+
* Start docker container container with `docker start ..`
|
491
|
+
* Provision container
|
492
|
+
|
493
|
+
|
494
|
+
|
483
495
|
# Other tools
|
484
496
|
|
485
497
|
* packer - https://github.com/mitchellh/packer
|
@@ -584,3 +596,28 @@ Process:
|
|
584
596
|
* docker start
|
585
597
|
* when container starts it runs /etc/boostrap which
|
586
598
|
* runs chef-client to provision server first time
|
599
|
+
|
600
|
+
|
601
|
+
|
602
|
+
## Bootstrap with shell script
|
603
|
+
|
604
|
+
* Dockerfile
|
605
|
+
|
606
|
+
* include script /opt/bootstrap/bootstrap.sh in container
|
607
|
+
```
|
608
|
+
ADD scripts/bootstrap.sh /opt/bootstrap/
|
609
|
+
|
610
|
+
RUN chmod +x /opt/bootstrap/bootstrap.sh
|
611
|
+
|
612
|
+
```
|
613
|
+
|
614
|
+
* config
|
615
|
+
|
616
|
+
```
|
617
|
+
'install' => {
|
618
|
+
"bootstrap" => { 'script_type' => 'shell', 'script' => '/opt/bootstrap/bootstrap.sh', },
|
619
|
+
},
|
620
|
+
|
621
|
+
|
622
|
+
```
|
623
|
+
|
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.30
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|