percheron 0.6.1 → 0.6.2

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: 0e3ddd051314e0499f89ac94434e3f8db4853d38
4
- data.tar.gz: 2920032bebd374d9fdf48f1147a98cadd83a8c9b
3
+ metadata.gz: 184231c68ed6ae113dd7f46af5290a523b098066
4
+ data.tar.gz: f9abacfe6fb20d642faecd4719bd1a0294183158
5
5
  SHA512:
6
- metadata.gz: 8e35dd0de12e652c68904d9759c274c4e603929dbd9fd97419ad9d6c8a6527d41c5e1e34985879958c5fb7d8904ccbb1f5ffe2c2b3f7d53a4598b67018676216
7
- data.tar.gz: 870da0edb41d07986ee64aef65a7dac5cfd71536a411664c37aadbed476a408d6b3af9b9261397159b487a53102a2c8697e0179104746ba5d32a8c47e8f08268
6
+ metadata.gz: a08a95231a9a22eb805451da21768e17addb2da749778f59626ae4cee1b370e040051b7f6457549e18cd5efa247173716d8f120515405b04d2f6ba3254c6f5bc
7
+ data.tar.gz: 90a61d02bcbb222e44837526803a2a1a0da12f9b9f0fbbd2eafba03eee861160fc3528bbfff50937ff7ce024569a99cd5402e35973e5786d1937f449f52c9563
@@ -29,13 +29,19 @@ module Percheron
29
29
 
30
30
  def stop_containers!(containers)
31
31
  exec_on_containers!(containers) do |container|
32
- Stop.new(container).execute! if container.running?
32
+ if container.running?
33
+ $logger.debug "Stopping '#{container.name}' container"
34
+ Stop.new(container).execute!
35
+ end
33
36
  end
34
37
  end
35
38
 
36
39
  def start_containers!(containers)
37
40
  exec_on_containers!(containers) do |container|
38
- Start.new(container, container.dependant_containers.values).execute! unless container.running?
41
+ unless container.running?
42
+ $logger.debug "Starting '#{container.name}' container"
43
+ Start.new(container, container.dependant_containers.values).execute!
44
+ end
39
45
  end
40
46
  end
41
47
 
@@ -29,8 +29,7 @@ module Percheron
29
29
 
30
30
  def build!
31
31
  in_working_directory(base_dir) do
32
- execute_pre_build_scripts!
33
-
32
+ execute_pre_build_scripts! unless container.pre_build_scripts.empty?
34
33
  $logger.info "Building '#{container.image_name}'"
35
34
  Docker::Image.build_from_dir(base_dir, build_opts) do |out|
36
35
  $logger.debug '%s' % [ out.strip ]
@@ -39,7 +38,7 @@ module Percheron
39
38
  end
40
39
 
41
40
  def execute_pre_build_scripts!
42
- Exec.new(container, container.dependant_containers.values, container.pre_build_scripts, 'PRE build').execute!
41
+ ExecLocal.new(container, container.pre_build_scripts, 'PRE build').execute!
43
42
  end
44
43
 
45
44
  end
@@ -64,7 +64,7 @@ module Percheron
64
64
  build_image!
65
65
  insert_scripts!
66
66
  create_container!(opts.fetch(:create, {}))
67
- execute_post_create_scripts!
67
+ execute_post_create_scripts! unless container.post_create_scripts.empty?
68
68
  set_dockerfile_md5!
69
69
  end
70
70
 
@@ -0,0 +1,43 @@
1
+ require 'open3'
2
+
3
+ module Percheron
4
+ module Actions
5
+ class ExecLocal
6
+
7
+ include Base
8
+
9
+ def initialize(container, scripts, description)
10
+ @container = container
11
+ @scripts = scripts
12
+ @description = description
13
+ end
14
+
15
+ def execute!
16
+ $logger.debug "Executing #{description} scripts '#{scripts.inspect}' locally"
17
+ execute_scripts!
18
+ end
19
+
20
+ private
21
+
22
+ attr_reader :container, :scripts, :description
23
+
24
+ def execute_scripts!
25
+ scripts.each do |script|
26
+ in_working_directory(base_dir) do
27
+ execute_command!('/bin/bash -x %s 2>&1' % Pathname.new(File.expand_path(script)))
28
+ end
29
+ end
30
+ end
31
+
32
+ def execute_command!(command)
33
+ $logger.info "Executing #{description} '#{command}' locally"
34
+ Open3.popen2e(command) do |stdin, stdout_stderr, wait_thr|
35
+ while line = stdout_stderr.gets
36
+ $logger.debug line.strip
37
+ end
38
+ end
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -11,8 +11,10 @@ module Percheron
11
11
 
12
12
  def execute!
13
13
  create_or_recreate!
14
- start! unless container.running?
15
- execute_post_start_scripts! unless container.post_start_scripts.empty?
14
+ unless container.running?
15
+ start!
16
+ execute_post_start_scripts! unless container.post_start_scripts.empty?
17
+ end
16
18
  container
17
19
  end
18
20
 
@@ -8,6 +8,7 @@ require 'percheron/actions/rename'
8
8
  require 'percheron/actions/build'
9
9
  require 'percheron/actions/purge'
10
10
  require 'percheron/actions/exec'
11
+ require 'percheron/actions/exec_local'
11
12
 
12
13
  module Percheron
13
14
  module Actions
@@ -1,3 +1,3 @@
1
1
  module Percheron
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: percheron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ash McKenzie
@@ -231,6 +231,7 @@ files:
231
231
  - lib/percheron/actions/build.rb
232
232
  - lib/percheron/actions/create.rb
233
233
  - lib/percheron/actions/exec.rb
234
+ - lib/percheron/actions/exec_local.rb
234
235
  - lib/percheron/actions/purge.rb
235
236
  - lib/percheron/actions/recreate.rb
236
237
  - lib/percheron/actions/rename.rb