dockerhelper 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/dockerhelper.rb +1 -3
- data/lib/dockerhelper/config.rb +22 -0
- data/lib/dockerhelper/kubernetes.rb +2 -3
- data/lib/dockerhelper/rake.rb +33 -25
- data/lib/dockerhelper/version.rb +1 -1
- 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: 9178187c9e138e25855fd94d4d748f3ec5ba8b23
|
4
|
+
data.tar.gz: 87f038059e71d699b79c678cc9f581f22141b625
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5cb7334b53cc21763ea48a91bcc05237e67d65708e9210071f5a73d8a739f96873a2afa9a6ce79e3a91e4eb5c5281ca421c7dd7f027c7fb28124e697a61c5df
|
7
|
+
data.tar.gz: 02744ba8492b5ba8aa96f2218fd6b0d9e5258ea9c43793118ef07f611d7fc52ffc6268e8dc7371103710c582c056b1d570a350527e65c90d876979dad6c426b5
|
data/README.md
CHANGED
@@ -41,6 +41,7 @@ config = Dockerhelper.configure do |c|
|
|
41
41
|
c.docker_repo_tag_prefix = 'prd-'
|
42
42
|
c.kube_rc_template = File.expand_path('../project-rc.yml.erb', __FILE__)
|
43
43
|
c.kube_rc_dest_dir = File.dirname(__FILE__)
|
44
|
+
c.env_vars = %w(REQUIRED_ENV_VAR)
|
44
45
|
end
|
45
46
|
|
46
47
|
Dockerhelper::Tasks.init(config)
|
data/lib/dockerhelper.rb
CHANGED
data/lib/dockerhelper/config.rb
CHANGED
@@ -13,6 +13,9 @@ module Dockerhelper
|
|
13
13
|
attr_accessor :environment
|
14
14
|
attr_accessor :kube_rc_template
|
15
15
|
attr_accessor :kube_rc_dest_dir
|
16
|
+
attr_accessor :kube_rc_version
|
17
|
+
attr_accessor :env_vars
|
18
|
+
attr_accessor :prebuild_command
|
16
19
|
|
17
20
|
def initialize
|
18
21
|
# defaults
|
@@ -28,6 +31,10 @@ module Dockerhelper
|
|
28
31
|
@docker ||= Docker.new(chdir: git_root)
|
29
32
|
end
|
30
33
|
|
34
|
+
def kubernetes?
|
35
|
+
@kube_rc_template && @kube_rc_dest_dir
|
36
|
+
end
|
37
|
+
|
31
38
|
def kubernetes
|
32
39
|
@kubernetes ||= Kubernetes.new(self)
|
33
40
|
end
|
@@ -35,5 +42,20 @@ module Dockerhelper
|
|
35
42
|
def docker_repo_tag
|
36
43
|
@docker_tag || "#{docker_repo_tag_prefix}#{git.latest_rev}"
|
37
44
|
end
|
45
|
+
|
46
|
+
def check_env_vars!
|
47
|
+
return unless env_vars
|
48
|
+
unless env_vars.respond_to?(:reject)
|
49
|
+
raise ArgumentError.new('Expected an array of env_vars')
|
50
|
+
end
|
51
|
+
undefined = env_vars.reject(&ENV.method(:has_key?))
|
52
|
+
unless undefined.empty?
|
53
|
+
raise StandardError.new("The environment must define #{undefined.join ', '}")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def prebuild?
|
58
|
+
prebuild_command && !prebuild_command.empty?
|
59
|
+
end
|
38
60
|
end
|
39
61
|
end
|
@@ -13,7 +13,7 @@ module Dockerhelper
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def app_version
|
16
|
-
config.docker_repo_tag
|
16
|
+
config.kube_rc_version || config.docker_repo_tag
|
17
17
|
end
|
18
18
|
|
19
19
|
def app_full_name
|
@@ -39,8 +39,7 @@ module Dockerhelper
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def replication_controller_delete
|
42
|
-
Command.new("kubectl delete
|
43
|
-
label: 'kubectl-delete-rc').run
|
42
|
+
Command.new("kubectl delete rc #{current_rc}", label: 'kubectl-delete-rc').run
|
44
43
|
end
|
45
44
|
|
46
45
|
def replication_controller_yaml
|
data/lib/dockerhelper/rake.rb
CHANGED
@@ -5,14 +5,21 @@ module Dockerhelper
|
|
5
5
|
extend ::Rake::DSL
|
6
6
|
|
7
7
|
def self.init(config)
|
8
|
+
build_tasks = [:pull, :docker_build, :repo_tag, :push]
|
9
|
+
build_tasks << :'kube:gen_rc' if config.kubernetes?
|
10
|
+
|
8
11
|
namespace :docker do
|
9
12
|
namespace(config.environment) do
|
10
|
-
|
11
13
|
desc 'Print config info'
|
12
14
|
task :info do
|
13
15
|
puts config.inspect
|
14
16
|
end
|
15
17
|
|
18
|
+
desc 'Prepare to build docker image'
|
19
|
+
task :prebuild do
|
20
|
+
Command.new(config.prebuild_command, label: 'prebuild').run if config.prebuild?
|
21
|
+
end
|
22
|
+
|
16
23
|
desc 'Build docker image'
|
17
24
|
task :docker_build do
|
18
25
|
config.docker.build(config.dockerfile, tag: config.docker_image)
|
@@ -35,34 +42,36 @@ module Dockerhelper
|
|
35
42
|
end
|
36
43
|
|
37
44
|
desc 'Git clone, build image, and push image to Docker Hub'
|
38
|
-
task :build =>
|
45
|
+
task :build => build_tasks
|
39
46
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
47
|
+
if config.kubernetes?
|
48
|
+
namespace :kube do
|
49
|
+
desc 'Generate replication controller for the current build'
|
50
|
+
task :gen_rc do
|
51
|
+
config.kubernetes.write_replication_controller
|
52
|
+
puts "Created replication-controller: #{config.kubernetes.replication_controller_filename}"
|
53
|
+
end
|
46
54
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
55
|
+
desc 'Get current replication controller version'
|
56
|
+
task :current_rc do
|
57
|
+
puts config.kubernetes.current_rc
|
58
|
+
end
|
51
59
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
60
|
+
desc 'Run replication controller rolling-update'
|
61
|
+
task :rolling_update => [:gen_rc] do
|
62
|
+
config.kubernetes.rolling_update
|
63
|
+
end
|
56
64
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
65
|
+
desc 'Create replication controller'
|
66
|
+
task :create_rc => [:gen_rc] do
|
67
|
+
config.kubernetes.replication_controller_create
|
68
|
+
end
|
61
69
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
70
|
+
desc 'Delete replication controller (USE WITH CAUTION)'
|
71
|
+
task :delete_rc do
|
72
|
+
# TODO add "are you sure?" prompt
|
73
|
+
config.kubernetes.replication_controller_delete
|
74
|
+
end
|
66
75
|
end
|
67
76
|
end
|
68
77
|
end
|
@@ -70,4 +79,3 @@ module Dockerhelper
|
|
70
79
|
end
|
71
80
|
end
|
72
81
|
end
|
73
|
-
|
data/lib/dockerhelper/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.5
|
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-
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|