dockerize_rails 1.1.0.beta.1 → 1.1.0.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/lib/dockerize_rails/command_line_methods.rb +6 -4
- data/lib/dockerize_rails/constants.rb +6 -6
- data/lib/dockerize_rails/docker_commands/docker_build.rb +67 -0
- data/lib/dockerize_rails/docker_commands/docker_pull.rb +54 -0
- data/lib/dockerize_rails/docker_commands.rb +35 -0
- data/lib/dockerize_rails/version.rb +1 -1
- data/lib/dockerize_rails.rb +8 -2
- metadata +5 -3
- data/lib/dockerize_rails/docker_helper.rb +0 -108
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca024b782016296d6dd369e5f7842a525d598544
|
4
|
+
data.tar.gz: 5ed08757b71becb915159024a092a979b55f3e31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfe6c01187bfbf50798b1df846618b55bd2ebd315d80de032c6de84f58573cc3df64ad7f8631f61f0448cb173d67ce6e9ced0e97faabd7411943357be10fabae
|
7
|
+
data.tar.gz: 58adaf8d3988d96a03c6991a582691b77a849f7088598b186ff5f4f2541e09a21749a3fc92af8961beba4796cd2aa8b0ff4f56e9b27ce915b7de4d1d4e5e7b4d
|
data/.rubocop.yml
CHANGED
@@ -3,6 +3,7 @@ module DockerizeRails
|
|
3
3
|
require 'colorize'
|
4
4
|
|
5
5
|
# rubocop:disable Metrics/MethodLength
|
6
|
+
# rubocop:disable Metrics/AbcSize
|
6
7
|
def self.invoke(options)
|
7
8
|
DRNameSpace.add_hash options[1][:args]
|
8
9
|
commands = Helpers.processed_commands
|
@@ -26,6 +27,7 @@ module DockerizeRails
|
|
26
27
|
end
|
27
28
|
end
|
28
29
|
# rubocop:enable Metrics/MethodLength
|
30
|
+
# rubocop:enable Metrics/AbcSize
|
29
31
|
|
30
32
|
def self.dockerize
|
31
33
|
Helpers.ensure_rails_root
|
@@ -50,7 +52,7 @@ module DockerizeRails
|
|
50
52
|
end
|
51
53
|
|
52
54
|
def self.docker_info
|
53
|
-
docker_version =
|
55
|
+
docker_version = DockerCommands.version
|
54
56
|
|
55
57
|
puts
|
56
58
|
Helpers.print_formatted_info 'Docker Version', "#{docker_version['Version']}\n"
|
@@ -67,14 +69,14 @@ module DockerizeRails
|
|
67
69
|
|
68
70
|
def self.docker_pull
|
69
71
|
DRNameSpace.load
|
70
|
-
DockerizeRails::
|
72
|
+
DockerizeRails::DockerCommands.pull
|
71
73
|
0
|
72
74
|
end
|
73
75
|
|
74
76
|
def self.docker_build
|
75
77
|
DRNameSpace.load
|
76
|
-
DockerizeRails::
|
77
|
-
|
78
|
+
DockerizeRails::DockerCommands.build
|
79
|
+
0
|
78
80
|
end
|
79
81
|
end
|
80
82
|
end
|
@@ -39,16 +39,16 @@ module DockerizeRails
|
|
39
39
|
}
|
40
40
|
},
|
41
41
|
docker_info: {
|
42
|
-
|
43
|
-
|
42
|
+
aliases: %I[docker_info di],
|
43
|
+
help: 'Shows Docker information'.freeze
|
44
44
|
},
|
45
45
|
docker_pull: {
|
46
|
-
|
47
|
-
|
46
|
+
aliases: %I[docker_pull pull dp],
|
47
|
+
help: 'Pulls Docker images'.freeze
|
48
48
|
},
|
49
49
|
docker_build: {
|
50
|
-
|
51
|
-
|
50
|
+
aliases: %I[docker_build build db],
|
51
|
+
help: 'Builds Docker images'.freeze
|
52
52
|
},
|
53
53
|
help: {
|
54
54
|
aliases: %I[help h],
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module DockerizeRails
|
2
|
+
module DockerCommands
|
3
|
+
module DockerBuild
|
4
|
+
def self.build_rails
|
5
|
+
build_docker_image(
|
6
|
+
"#{Constants::CONFIG_DIRECTORY_NAME}/#{Constants::RAILS_DIRECTORY_NAME}/Dockerfile",
|
7
|
+
"#{DRConfig.application_name}_mysql"
|
8
|
+
)
|
9
|
+
0
|
10
|
+
rescue Docker::Error::NotFoundError => exception
|
11
|
+
puts
|
12
|
+
puts exception.to_s.red
|
13
|
+
puts
|
14
|
+
1
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.build_mysql
|
18
|
+
if DRConfig.linked_database? && DRConfig.databases[DRConfig.application_env] == 'mysql'
|
19
|
+
build_docker_image(
|
20
|
+
"#{Constants::CONFIG_DIRECTORY_NAME}/#{Constants::MYSQL_DIRECTORY_NAME}/Dockerfile",
|
21
|
+
"#{DRConfig.application_name}_mysql"
|
22
|
+
)
|
23
|
+
end
|
24
|
+
0
|
25
|
+
rescue Docker::Error::NotFoundError => exception
|
26
|
+
puts
|
27
|
+
puts exception.to_s.red
|
28
|
+
puts
|
29
|
+
1
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.build_postgres
|
33
|
+
if DRConfig.linked_database? && DRConfig.databases[DRConfig.application_env] == 'postgresql'
|
34
|
+
build_docker_image(
|
35
|
+
"#{Constants::CONFIG_DIRECTORY_NAME}/#{Constants::PG_DIRECTORY_NAME}/Dockerfile",
|
36
|
+
"#{DRConfig.application_name}_postgres"
|
37
|
+
)
|
38
|
+
end
|
39
|
+
0
|
40
|
+
rescue Docker::Error::NotFoundError => exception
|
41
|
+
puts
|
42
|
+
puts exception.to_s.red
|
43
|
+
puts
|
44
|
+
1
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.build_docker_image(dockerfile, repo)
|
48
|
+
image = Docker::Image.build_from_dir(
|
49
|
+
'.',
|
50
|
+
dockerfile: dockerfile
|
51
|
+
)
|
52
|
+
image.tag(repo: repo, tag: DRConfig.application_env)
|
53
|
+
puts "Image '#{repo}:#{DRConfig.application_env}' build success".green
|
54
|
+
0
|
55
|
+
rescue Docker::Error::NotFoundError => exception
|
56
|
+
puts
|
57
|
+
puts exception.to_s.red
|
58
|
+
puts
|
59
|
+
1
|
60
|
+
end
|
61
|
+
|
62
|
+
class << self
|
63
|
+
private :build_docker_image
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module DockerizeRails
|
2
|
+
module DockerCommands
|
3
|
+
module DockerPull
|
4
|
+
def self.pull_ruby
|
5
|
+
pull_docker_image('ruby', DRConfig.ruby_version)
|
6
|
+
0
|
7
|
+
rescue Docker::Error::NotFoundError => exception
|
8
|
+
puts
|
9
|
+
puts exception.to_s.red
|
10
|
+
puts
|
11
|
+
1
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.pull_mysql
|
15
|
+
if DRConfig.linked_database? && DRConfig.databases[DRConfig.application_env] == 'mysql'
|
16
|
+
pull_docker_image('mysql', DRConfig.mysql_version)
|
17
|
+
end
|
18
|
+
0
|
19
|
+
rescue Docker::Error::NotFoundError => exception
|
20
|
+
puts
|
21
|
+
puts exception.to_s.red
|
22
|
+
puts
|
23
|
+
1
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.pull_postgres
|
27
|
+
if DRConfig.linked_database? && DRConfig.databases[DRConfig.application_env] == 'postgresql'
|
28
|
+
pull_docker_image('postgres', DRConfig.postgres_version)
|
29
|
+
end
|
30
|
+
0
|
31
|
+
rescue Docker::Error::NotFoundError => exception
|
32
|
+
puts
|
33
|
+
puts exception.to_s.red
|
34
|
+
puts
|
35
|
+
1
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.pull_docker_image(image_name, tag)
|
39
|
+
Docker::Image.create('fromImage' => "#{image_name}:#{tag}")
|
40
|
+
puts "Base image '#{image_name}:#{tag}' ready".green
|
41
|
+
0
|
42
|
+
rescue Docker::Error::NotFoundError => exception
|
43
|
+
puts
|
44
|
+
puts exception.to_s.red
|
45
|
+
puts
|
46
|
+
1
|
47
|
+
end
|
48
|
+
|
49
|
+
class << self
|
50
|
+
private :pull_docker_image
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module DockerizeRails
|
2
|
+
module DockerCommands
|
3
|
+
require 'docker'
|
4
|
+
|
5
|
+
def self.version
|
6
|
+
Docker.version
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.pull
|
10
|
+
status = 0
|
11
|
+
status += DockerPull.pull_ruby
|
12
|
+
status += DockerPull.pull_mysql
|
13
|
+
status += DockerPull.pull_postgres
|
14
|
+
status
|
15
|
+
rescue Docker::Error::NotFoundError => exception
|
16
|
+
puts
|
17
|
+
puts exception.to_s.red
|
18
|
+
puts
|
19
|
+
1
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.build
|
23
|
+
status = 0
|
24
|
+
status += DockerBuild.build_rails
|
25
|
+
status += DockerBuild.build_postgres
|
26
|
+
status += DockerBuild.build_mysql
|
27
|
+
status
|
28
|
+
rescue Docker::Error::NotFoundError => exception
|
29
|
+
puts
|
30
|
+
puts exception.to_s.red
|
31
|
+
puts
|
32
|
+
1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/dockerize_rails.rb
CHANGED
@@ -7,7 +7,9 @@ require 'dockerize_rails/dr_config'
|
|
7
7
|
require 'dockerize_rails/config_loader'
|
8
8
|
require 'dockerize_rails/dr_name_space'
|
9
9
|
require 'dockerize_rails/config_generator'
|
10
|
-
require 'dockerize_rails/
|
10
|
+
require 'dockerize_rails/docker_commands/docker_pull'
|
11
|
+
require 'dockerize_rails/docker_commands/docker_build'
|
12
|
+
require 'dockerize_rails/docker_commands'
|
11
13
|
require 'dockerize_rails/command_line_methods'
|
12
14
|
require 'dockerize_rails/command_line'
|
13
15
|
|
@@ -18,10 +20,14 @@ module DockerizeRails
|
|
18
20
|
private_constant :ConfigLoader
|
19
21
|
private_constant :DRConfig
|
20
22
|
private_constant :ConfigGenerator
|
21
|
-
private_constant :DockerHelper
|
22
23
|
private_constant :Constants
|
23
24
|
private_constant :Templates
|
24
25
|
private_constant :CommandLineMethods
|
26
|
+
|
27
|
+
module DockerCommands
|
28
|
+
private_constant :DockerPull
|
29
|
+
private_constant :DockerBuild
|
30
|
+
end
|
25
31
|
end
|
26
32
|
|
27
33
|
class DockerizeRailsCLI
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dockerize_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.0.beta.
|
4
|
+
version: 1.1.0.beta.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- indrajit
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docker-api
|
@@ -137,7 +137,9 @@ files:
|
|
137
137
|
- lib/dockerize_rails/config_generator.rb
|
138
138
|
- lib/dockerize_rails/config_loader.rb
|
139
139
|
- lib/dockerize_rails/constants.rb
|
140
|
-
- lib/dockerize_rails/
|
140
|
+
- lib/dockerize_rails/docker_commands.rb
|
141
|
+
- lib/dockerize_rails/docker_commands/docker_build.rb
|
142
|
+
- lib/dockerize_rails/docker_commands/docker_pull.rb
|
141
143
|
- lib/dockerize_rails/dr_config.rb
|
142
144
|
- lib/dockerize_rails/dr_name_space.rb
|
143
145
|
- lib/dockerize_rails/helpers.rb
|
@@ -1,108 +0,0 @@
|
|
1
|
-
module DockerizeRails
|
2
|
-
module DockerHelper
|
3
|
-
require 'docker'
|
4
|
-
|
5
|
-
def self.version
|
6
|
-
Docker.version
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.pull
|
10
|
-
status = 0
|
11
|
-
Docker::Image.create('fromImage' => "ruby:#{DRConfig.ruby_version}")
|
12
|
-
puts "Base image 'ruby:#{DRConfig.ruby_version}' ready".green
|
13
|
-
status += pull_mysql
|
14
|
-
status += pull_postgres
|
15
|
-
status
|
16
|
-
rescue Docker::Error::NotFoundError => e
|
17
|
-
puts
|
18
|
-
puts e.to_s.red
|
19
|
-
puts
|
20
|
-
1
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.build
|
24
|
-
status = 0
|
25
|
-
image = Docker::Image.build_from_dir(
|
26
|
-
'.',
|
27
|
-
dockerfile: "#{Constants::CONFIG_DIRECTORY_NAME}/#{Constants::RAILS_DIRECTORY_NAME}/Dockerfile"
|
28
|
-
)
|
29
|
-
image.tag(repo: "#{DRConfig.application_name}_rails", tag: "#{DRConfig.application_env}")
|
30
|
-
puts "Image '#{DRConfig.application_name}_rails:#{DRConfig.application_env}' build success".green
|
31
|
-
status += build_postgres
|
32
|
-
status += build_mysql
|
33
|
-
status
|
34
|
-
rescue Docker::Error::NotFoundError => e
|
35
|
-
puts
|
36
|
-
puts e.to_s.red
|
37
|
-
puts
|
38
|
-
1
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.pull_mysql
|
42
|
-
if DRConfig.linked_database? && DRConfig.databases[DRConfig.application_env] == 'mysql'
|
43
|
-
Docker::Image.create('fromImage' => "mysql:#{DRConfig.mysql_version}")
|
44
|
-
puts "Base image 'mysql:#{DRConfig.mysql_version}' ready".green
|
45
|
-
end
|
46
|
-
0
|
47
|
-
rescue Docker::Error::NotFoundError => e
|
48
|
-
puts
|
49
|
-
puts e.to_s.red
|
50
|
-
puts
|
51
|
-
1
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.pull_postgres
|
55
|
-
if DRConfig.linked_database? && DRConfig.databases[DRConfig.application_env] == 'postgresql'
|
56
|
-
Docker::Image.create('fromImage' => "postgres:#{DRConfig.postgres_version}")
|
57
|
-
puts "Base image 'postgres:#{DRConfig.postgres_version}' ready".green
|
58
|
-
end
|
59
|
-
0
|
60
|
-
rescue Docker::Error::NotFoundError => e
|
61
|
-
puts
|
62
|
-
puts e.to_s.red
|
63
|
-
puts
|
64
|
-
1
|
65
|
-
end
|
66
|
-
|
67
|
-
def self.build_mysql
|
68
|
-
if DRConfig.linked_database? && DRConfig.databases[DRConfig.application_env] == 'mysql'
|
69
|
-
image = Docker::Image.build_from_dir(
|
70
|
-
'.',
|
71
|
-
dockerfile: "#{Constants::CONFIG_DIRECTORY_NAME}/#{Constants::MYSQL_DIRECTORY_NAME}/Dockerfile"
|
72
|
-
)
|
73
|
-
image.tag(repo: "#{DRConfig.application_name}_mysql", tag: "#{DRConfig.application_env}")
|
74
|
-
puts "Image '#{DRConfig.application_name}_mysql:#{DRConfig.application_env}' build success".green
|
75
|
-
end
|
76
|
-
0
|
77
|
-
rescue Docker::Error::NotFoundError => e
|
78
|
-
puts
|
79
|
-
puts e.to_s.red
|
80
|
-
puts
|
81
|
-
1
|
82
|
-
end
|
83
|
-
|
84
|
-
def self.build_postgres
|
85
|
-
if DRConfig.linked_database? && DRConfig.databases[DRConfig.application_env] == 'postgresql'
|
86
|
-
image = Docker::Image.build_from_dir(
|
87
|
-
'.',
|
88
|
-
dockerfile: "#{Constants::CONFIG_DIRECTORY_NAME}/#{Constants::PG_DIRECTORY_NAME}/Dockerfile"
|
89
|
-
)
|
90
|
-
image.tag(repo: "#{DRConfig.application_name}_postgres", tag: "#{DRConfig.application_env}")
|
91
|
-
puts "Image '#{DRConfig.application_name}_postgres:#{DRConfig.application_env}' build success".green
|
92
|
-
end
|
93
|
-
0
|
94
|
-
rescue Docker::Error::NotFoundError => e
|
95
|
-
puts
|
96
|
-
puts e.to_s.red
|
97
|
-
puts
|
98
|
-
1
|
99
|
-
end
|
100
|
-
|
101
|
-
class << self
|
102
|
-
private :build_mysql
|
103
|
-
private :build_postgres
|
104
|
-
private :pull_mysql
|
105
|
-
private :pull_postgres
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|