brocket 0.0.3 → 0.1.0

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: 22fcf9e97f299b10983753dd1f74abb4ff31e78e
4
- data.tar.gz: 25a8ecaa347cd4db902508ac1112b6e98bb7e9dc
3
+ metadata.gz: 82018431e2aef0462f2a1197c516853c210f55d1
4
+ data.tar.gz: 096d374c5c647fd2a5d7463c1e865e1ce38ceaf1
5
5
  SHA512:
6
- metadata.gz: 20a13369ec5c253483e84cdafe5a42f194727db5fa98e37498404dfb8a9b430d409e5d43861aa2e89878c901b35ae5944287e57fc86fb7eee6a90131dc6f3d59
7
- data.tar.gz: efb682c5a4332b1685af273e00a17e182a02f0ebc9911ce3a38096fc10fd79f65062a51ed51718879e00782e927f5f4b0f72c2d9c79aa3bc10129be6b715f812
6
+ metadata.gz: 96f605adec1bea26494c75bf5c6831aa43d1b6d180fc27d9821ef50821ad3ef85a91ee5906715b2d62879289f037ed7a850154e926f58049754a06aac8ff5c95
7
+ data.tar.gz: 169748729b2b2531b6b24ba9e382922940657df14944df8c9156c0fc6ccfad6cd0a80e4debb48c55bc61dc656d3522f6b23df441051d17a83d1165058761109f
data/README.md CHANGED
@@ -1,7 +1,22 @@
1
1
  # brocket
2
2
 
3
3
  brocket supports to build docker image with VERSION file and git.
4
- brocket perfoms like rake tasks generated by `bundle gem` command.
4
+ You can define setup and teardown around `docker build` by writing
5
+ config IMAGE_NAME and hooks like BEFORE_BUILD and AFTER_BUILD.
6
+
7
+ ## Behavior
8
+
9
+ - `brocket release`
10
+ 1. check the local repository si clean and commited
11
+ 2. same as `brocket docker build`
12
+ 3. push by git
13
+ 4. push by docker
14
+ - `brocket docker build`
15
+ 1. call BEFORE_BUILD
16
+ 2. `docker build` with arguments
17
+ - call ON_BUILD_COMPLETE on success
18
+ - call ON_BUILD_ERROR on failure
19
+ 3. call AFTER_BUILD
5
20
 
6
21
  ## Installation
7
22
 
@@ -51,7 +66,7 @@ brocket version bump # bump up last number of VERSION file
51
66
 
52
67
  ### Hooks
53
68
 
54
- You can define commands to execute around build like this:
69
+ You can define commands to execute around `docker build` like this:
55
70
 
56
71
  ```
57
72
  # [config] IMAGE_NAME: "groovenauts/rails-example"
data/brocket.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_runtime_dependency "thor"
22
+ spec.add_runtime_dependency "logger_pipe"
22
23
 
23
24
  spec.add_development_dependency "bundler", "~> 1.6"
24
25
  spec.add_development_dependency "rake", "~> 10.0"
data/lib/brocket/base.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require "brocket"
2
2
 
3
+ require 'logger'
4
+
3
5
  require 'thor'
6
+ require 'logger_pipe'
4
7
 
5
8
  module BRocket
6
9
  class Base < Thor
@@ -28,39 +31,26 @@ module BRocket
28
31
  end
29
32
 
30
33
  def verbose(msg)
31
- $stderr.puts("\e[34m#{msg}\e[0m") if verbose?
34
+ logger.debug("\e[34m#{msg}\e[0m") if verbose?
32
35
  end
33
36
 
34
37
  def info(msg)
35
- $stderr.puts(msg)
38
+ logger.info(msg)
36
39
  end
37
40
  def success(msg)
38
- $stderr.puts("\e[32m#{msg}\e[0m")
41
+ logger.info("\e[32m#{msg}\e[0m")
39
42
  end
40
43
 
41
44
  def error(msg)
42
45
  raise BuildError, msg
43
46
  end
44
47
 
45
- def sh(cmd, &block)
46
- out, code = sh_with_code(cmd, &block)
47
- code == 0 ? out : error(out.empty? ? "Running `#{cmd}' failed. Run this command directly for more detailed output." : out)
48
+ def logger
49
+ @logger ||= Logger.new($stderr)
48
50
  end
49
51
 
50
- def sh_with_code(cmd, &block)
51
- cmd << " 2>&1"
52
- verbose(cmd)
53
- outbuf = ''
54
- if dryrun?
55
- block.call(outbuf) if block
56
- ["DRYRUN", 0]
57
- else
58
- outbuf = `#{cmd}`
59
- if $? == 0
60
- block.call(outbuf) if block
61
- end
62
- [outbuf, $?]
63
- end
52
+ def sh(cmd, &block)
53
+ LoggerPipe.run(logger, cmd + " 2>&1", dry_run: dryrun?)
64
54
  end
65
55
 
66
56
  end
@@ -43,6 +43,16 @@ module BRocket
43
43
  success("[docker push] OK")
44
44
  end
45
45
 
46
+ desc "call_before_build", "call BEFORE_BUILD callback manually"
47
+ def call_before_build
48
+ execute(config_hash['BEFORE_BUILD'])
49
+ end
50
+
51
+ desc "call_after_build", "call AFTER_BUILD callback manually"
52
+ def call_after_build
53
+ execute(config_hash['AFTER_BUILD'])
54
+ end
55
+
46
56
  no_commands do
47
57
  def config_image_name(c)
48
58
  img_name = (c['IMAGE_NAME'] || '').strip
@@ -1,3 +1,3 @@
1
1
  module BRocket
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brocket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - akima
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-20 00:00:00.000000000 Z
11
+ date: 2015-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: logger_pipe
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -118,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
132
  version: '0'
119
133
  requirements: []
120
134
  rubyforge_project:
121
- rubygems_version: 2.2.2
135
+ rubygems_version: 2.4.5
122
136
  signing_key:
123
137
  specification_version: 4
124
138
  summary: supports to build Docker Container with VERSION
@@ -131,4 +145,3 @@ test_files:
131
145
  - spec/brocket/version_file_spec.rb
132
146
  - spec/brocket_spec.rb
133
147
  - spec/spec_helper.rb
134
- has_rdoc: