dockerhelper 0.0.1 → 0.0.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: 175951aa3c1e8a37f9ae332f110502b62fc79e15
4
- data.tar.gz: 469962fce86e7d83ddb6cdda06adedc5b5e52b0b
3
+ metadata.gz: 11aee8a2639b071b1046e9ce1350ded31ab29c13
4
+ data.tar.gz: fdf0f3155c16c9c6b47fda301187ed1a8e92f093
5
5
  SHA512:
6
- metadata.gz: 6b0325ed7ff753b267495f3d042c3dd92b27ae1a1fc7922d270b096c27adac6328f8c09c176bb118f9f42f3929d7bb1785b4c32dea8bc8d8ad20fd2fca27a586
7
- data.tar.gz: 7733b57ed2f9e536efe233b6cc4186dad97852794839b32f57751db8adf62c7f6b1afd504d95dbfe2d78241af42e177c255f1d0f0b50a47683d71b14d1a8b179
6
+ metadata.gz: 9a4c542ef90e9cf2071f06b285133231af45d5ca70a4e52c24660d9ab41decfa1a1c81fa2aa55d50181f9c95c8e418599e67d396c6d2d68f5cee3e654e6eda3b
7
+ data.tar.gz: bcfd7a3ee7659e0ef54b0a606d64bb208b15e9b1847eed7c567d6cd6bcb1e77fffd19130f2a189281a870faac0432de0693ddf9c33bfb7927951013469d2117f
@@ -0,0 +1,15 @@
1
+ module Dockerhelper
2
+ class Build
3
+ def initialize(config)
4
+ @builder = config
5
+ end
6
+
7
+ def git
8
+ @git ||= Git.new(config.git_repo, rev_length: config.rev_length)
9
+ end
10
+
11
+ def docker
12
+ @docker ||= Docker.new(chdir: config.git_repo)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,30 @@
1
+ module Dockerhelper
2
+ class Config
3
+ attr_accessor :git_root
4
+ attr_accessor :git_branch
5
+ attr_accessor :git_repo_url
6
+ attr_accessor :docker_repo
7
+ attr_accessor :docker_image
8
+ attr_accessor :docker_tag
9
+ attr_accessor :rev_length
10
+ attr_accessor :dockerfile
11
+ attr_accessor :docker_repo_tag_prefix
12
+
13
+ def initialize
14
+ # defaults
15
+ @rev_length = 8
16
+ end
17
+
18
+ def git
19
+ @git ||= Git.new(git_root, rev_length: rev_length)
20
+ end
21
+
22
+ def docker
23
+ @docker ||= Docker.new(chdir: git_root)
24
+ end
25
+
26
+ def docker_repo_tag
27
+ @docker_tag || "#{docker_repo_tag_prefix}#{git.latest_rev}"
28
+ end
29
+ end
30
+ end
@@ -1,8 +1,10 @@
1
1
  module Dockerhelper
2
2
  class Git
3
- attr_reader :git_root
4
- def initialize(git_root)
3
+ attr_reader :git_root, :rev_length
4
+
5
+ def initialize(git_root, rev_length: 8)
5
6
  @git_root = git_root
7
+ @rev_length = rev_length
6
8
  end
7
9
 
8
10
  def clone(git_repo_url, branch)
@@ -22,7 +24,7 @@ module Dockerhelper
22
24
  end
23
25
 
24
26
  def latest_rev
25
- rev_list[0..7]
27
+ rev_list[0...rev_length]
26
28
  end
27
29
  end
28
30
  end
@@ -0,0 +1,44 @@
1
+ require 'rake/dsl_definition'
2
+
3
+ module Dockerhelper
4
+ module Tasks
5
+ extend ::Rake::DSL
6
+
7
+ def self.init(config, environment: :production)
8
+ namespace :docker do
9
+ namespace(environment) do
10
+
11
+ desc 'Print config info'
12
+ task :info do
13
+ puts config.inspect
14
+ end
15
+
16
+ desc 'Build docker image'
17
+ task :build do
18
+ config.docker.build(config.dockerfile, tag: config.docker_image)
19
+ end
20
+
21
+ desc 'Pull git repo'
22
+ task :pull do
23
+ config.git.clone(config.git_repo_url, config.git_branch)
24
+ end
25
+
26
+ desc 'Tag docker image'
27
+ task :repo_tag do
28
+ tag_full = "#{config.docker_repo}:#{config.docker_repo_tag}"
29
+ config.docker.tag(config.docker_image, tag_full)
30
+ end
31
+
32
+ desc 'Push docker images to Docker Hub'
33
+ task :push do
34
+ config.docker.push(config.docker_repo, tag: config.docker_repo_tag)
35
+ end
36
+
37
+ desc 'Git clone, build image, and push image to Docker Hub'
38
+ task :deploy => [:pull, :build, :repo_tag, :push]
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+
@@ -1,3 +1,3 @@
1
1
  module Dockerhelper
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/dockerhelper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require "dockerhelper/build"
2
+ require "dockerhelper/config"
1
3
  require "dockerhelper/command"
2
4
  require "dockerhelper/docker"
3
5
  require "dockerhelper/git"
@@ -8,4 +10,10 @@ module Dockerhelper
8
10
  Command.new(cmd, label: label).run
9
11
  end
10
12
  module_function :cmd
13
+
14
+ def self.configure(&block)
15
+ config = Config.new
16
+ block.call(config)
17
+ config
18
+ end
11
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dockerhelper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh McDade
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-14 00:00:00.000000000 Z
11
+ date: 2015-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,9 +53,12 @@ files:
53
53
  - bin/setup
54
54
  - dockerhelper.gemspec
55
55
  - lib/dockerhelper.rb
56
+ - lib/dockerhelper/build.rb
56
57
  - lib/dockerhelper/command.rb
58
+ - lib/dockerhelper/config.rb
57
59
  - lib/dockerhelper/docker.rb
58
60
  - lib/dockerhelper/git.rb
61
+ - lib/dockerhelper/rake.rb
59
62
  - lib/dockerhelper/version.rb
60
63
  homepage: https://github.com/joshm1/dockerhelper
61
64
  licenses: []