dockerize_rails 1.2.0.beta.1 → 1.2.1.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.reek +1 -1
- data/.rubocop.yml +5 -4
- data/README.md +19 -15
- data/docs/DockerizeRails.html +2 -2
- data/docs/DockerizeRails/CommandLine.html +1 -1
- data/docs/DockerizeRailsCLI.html +1 -1
- data/docs/_index.html +1 -1
- data/docs/file.README.html +13 -7
- data/docs/index.html +13 -7
- data/docs/top-level-namespace.html +1 -1
- data/lib/dockerize_rails/command_line_methods.rb +0 -4
- data/lib/dockerize_rails/constants.rb +14 -6
- data/lib/dockerize_rails/docker_commands/docker_build.rb +47 -16
- data/lib/dockerize_rails/docker_commands/docker_delete.rb +2 -1
- data/lib/dockerize_rails/docker_commands/docker_helpers.rb +3 -7
- data/lib/dockerize_rails/docker_commands/docker_options.rb +3 -9
- data/lib/dockerize_rails/docker_commands/docker_start.rb +0 -2
- data/lib/dockerize_rails/docker_commands/docker_stop.rb +1 -1
- data/lib/dockerize_rails/dr_config.rb +0 -2
- data/lib/dockerize_rails/helpers.rb +3 -0
- data/lib/dockerize_rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0f5c116e835900009100990f620400c7d6fd838
|
4
|
+
data.tar.gz: fbcd44f672657f107db9e479285f554e2986b3bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d278eec9201dc7778fda1c7c9d9db8269b7d5c576c1b0ba58453b6822d97b08bdee226743c29690c8a01bf38acd97eaa20a211c73d3c75cfdb3e6018994bc4e0
|
7
|
+
data.tar.gz: 2ce9feb8a6ecea0e1e27e8b3d92eaba7ad28265166003f3ddbb8229bcf6b080dfc7e0c410e02ef030ec147cc6dd396896b0f7fbf42c6d03f71ab8fe494599021
|
data/.reek
CHANGED
data/.rubocop.yml
CHANGED
@@ -5,7 +5,7 @@ AllCops:
|
|
5
5
|
- 'vendor/**/*'
|
6
6
|
|
7
7
|
Lint/SafeNavigationChain:
|
8
|
-
|
8
|
+
Enabled: true
|
9
9
|
|
10
10
|
Metrics/LineLength:
|
11
11
|
Max: 120
|
@@ -17,16 +17,17 @@ Metrics/ModuleLength:
|
|
17
17
|
Max: 150
|
18
18
|
|
19
19
|
Metrics/MethodLength:
|
20
|
-
Max:
|
20
|
+
Max: 30
|
21
21
|
|
22
22
|
Metrics/AbcSize:
|
23
|
+
Enabled: false
|
23
24
|
Max: 20
|
24
25
|
|
25
26
|
Metrics/PerceivedComplexity:
|
26
|
-
Max:
|
27
|
+
Max: 15
|
27
28
|
|
28
29
|
Style/CyclomaticComplexity:
|
29
|
-
Max:
|
30
|
+
Max: 15
|
30
31
|
|
31
32
|
Style/BlockComments:
|
32
33
|
Enabled: false
|
data/README.md
CHANGED
@@ -16,8 +16,9 @@ gem 'dockerize_rails'
|
|
16
16
|
```
|
17
17
|
|
18
18
|
And then execute:
|
19
|
+
|
19
20
|
```bash
|
20
|
-
$ bundle
|
21
|
+
$ bundle install
|
21
22
|
```
|
22
23
|
|
23
24
|
## Usage
|
@@ -45,18 +46,15 @@ To remove docker configurations: `bundle exec dock undockerize`. Use `--purge` o
|
|
45
46
|
All available commands:
|
46
47
|
```bash
|
47
48
|
$ bundle exec dock help
|
48
|
-
$ bundle exec dock configure
|
49
|
-
$ bundle exec dock
|
50
|
-
$ bundle exec dock
|
51
|
-
$ bundle exec dock dockerize --test-env
|
52
|
-
$ bundle exec dock undockerize
|
53
|
-
$ bundle exec dock undockerize --purge
|
49
|
+
$ bundle exec dock configure [ --tiny ]
|
50
|
+
$ bundle exec dock dockerize [ --test-env ]
|
51
|
+
$ bundle exec dock undockerize [ --purge ]
|
54
52
|
$ bundle exec dock docker_info
|
55
53
|
$ bundle exec dock docker_pull
|
56
|
-
$ bundle exec dock docker_build
|
54
|
+
$ bundle exec dock docker_build [ --log | --rebuild | --rebuild --force ]
|
57
55
|
$ bundle exec dock docker_start
|
58
|
-
$ bundle exec dock docker_stop
|
59
|
-
$ bundle exec dock
|
56
|
+
$ bundle exec dock docker_stop [ --delete ]
|
57
|
+
$ bundle exec dock docker_delete [ --force ]
|
60
58
|
```
|
61
59
|
|
62
60
|
Help message:
|
@@ -67,26 +65,32 @@ Usage: dock <command>
|
|
67
65
|
commands:
|
68
66
|
|
69
67
|
configure, c, rc, cr - Generates '.dockerize.yml'
|
70
|
-
[--tiny] --
|
68
|
+
[--tiny] -- Generates shorter config file, skipping all descriptions
|
71
69
|
|
72
70
|
dockerize, dc, d - Generates docker config files
|
73
|
-
[--test-env] --
|
71
|
+
[--test-env] -- Generates configurations to run tests.
|
74
72
|
|
75
73
|
undockerize, ud, du, u, dd - Removes docker configurations
|
76
|
-
[--purge] --
|
74
|
+
[--purge] -- Also removes .dockerize.yml
|
77
75
|
|
78
76
|
docker_info, info - Shows Docker information
|
79
77
|
docker_pull, pull - Pulls base Docker images (ruby, mysql/postgres)
|
80
78
|
docker_build, build - Builds Docker images
|
79
|
+
[--log] -- Displays/Streams build log
|
80
|
+
[--rebuild] -- Deletes images if exists and rebuilds
|
81
|
+
[--force] -- Force Image deletion. Works only with --rebuild option
|
82
|
+
|
81
83
|
docker_start, start - Run/Starts Docker containers
|
82
84
|
docker_stop, stop - Stops Docker containers
|
83
|
-
[--delete] --
|
85
|
+
[--delete] -- Also deletes the containers
|
84
86
|
|
85
87
|
docker_delete, delete - Deletes Docker containers
|
88
|
+
[--force] -- Force Container deletion.
|
89
|
+
|
86
90
|
help, h - Prints this message
|
87
91
|
```
|
88
92
|
|
89
|
-
##
|
93
|
+
## Demonstration
|
90
94
|
|
91
95
|
[![asciicast](https://asciinema.org/a/121552.png)](https://asciinema.org/a/121552)
|
92
96
|
|
data/docs/DockerizeRails.html
CHANGED
@@ -102,7 +102,7 @@
|
|
102
102
|
<dt id="VERSION-constant" class="">VERSION =
|
103
103
|
|
104
104
|
</dt>
|
105
|
-
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1.2.
|
105
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>1.2.1.beta.1</span><span class='tstring_end'>'</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
|
106
106
|
|
107
107
|
</dl>
|
108
108
|
|
@@ -117,7 +117,7 @@
|
|
117
117
|
</div>
|
118
118
|
|
119
119
|
<div id="footer">
|
120
|
-
Generated on Sat Aug 12
|
120
|
+
Generated on Sat Aug 12 16:08:38 2017 by
|
121
121
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
122
122
|
0.9.9 (ruby-2.1.0).
|
123
123
|
</div>
|
@@ -169,7 +169,7 @@
|
|
169
169
|
</div>
|
170
170
|
|
171
171
|
<div id="footer">
|
172
|
-
Generated on Sat Aug 12
|
172
|
+
Generated on Sat Aug 12 16:08:38 2017 by
|
173
173
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
174
174
|
0.9.9 (ruby-2.1.0).
|
175
175
|
</div>
|
data/docs/DockerizeRailsCLI.html
CHANGED
@@ -127,7 +127,7 @@
|
|
127
127
|
</div>
|
128
128
|
|
129
129
|
<div id="footer">
|
130
|
-
Generated on Sat Aug 12
|
130
|
+
Generated on Sat Aug 12 16:08:38 2017 by
|
131
131
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
132
132
|
0.9.9 (ruby-2.1.0).
|
133
133
|
</div>
|
data/docs/_index.html
CHANGED
@@ -117,7 +117,7 @@
|
|
117
117
|
</div>
|
118
118
|
|
119
119
|
<div id="footer">
|
120
|
-
Generated on Sat Aug 12
|
120
|
+
Generated on Sat Aug 12 16:08:37 2017 by
|
121
121
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
122
122
|
0.9.9 (ruby-2.1.0).
|
123
123
|
</div>
|
data/docs/file.README.html
CHANGED
@@ -114,8 +114,10 @@ dock configure $ bundle exec dock configure --tiny $ bundle exec dock
|
|
114
114
|
dockerize $ bundle exec dock dockerize --test-env $ bundle exec dock
|
115
115
|
undockerize $ bundle exec dock undockerize --purge $ bundle exec dock
|
116
116
|
docker_info $ bundle exec dock docker_pull $ bundle exec dock docker_build
|
117
|
-
$ bundle exec dock
|
118
|
-
exec dock
|
117
|
+
$ bundle exec dock docker_build --log $ bundle exec dock docker_build
|
118
|
+
--rebuild $ bundle exec dock docker_build --rebuild --force $ bundle exec
|
119
|
+
dock docker_start $ bundle exec dock docker_stop $ bundle exec dock
|
120
|
+
docker_stop --delete $ bundle exec dock docker_delete </code></p>
|
119
121
|
|
120
122
|
<p>Help message: “` Usage: dock <command> or: bundle exec dock
|
121
123
|
<command></p>
|
@@ -123,20 +125,24 @@ exec dock docker_stop --delete </code></p>
|
|
123
125
|
<p>commands:</p>
|
124
126
|
|
125
127
|
<pre class="code ruby"><code class="ruby"> configure, c, rc, cr - Generates '.dockerize.yml'
|
126
|
-
[--tiny] --
|
128
|
+
[--tiny] -- Generates shorter config file, skipping all descriptions
|
127
129
|
|
128
130
|
dockerize, dc, d - Generates docker config files
|
129
|
-
[--test-env] --
|
131
|
+
[--test-env] -- Generates configurations to run tests.
|
130
132
|
|
131
133
|
undockerize, ud, du, u, dd - Removes docker configurations
|
132
|
-
[--purge] --
|
134
|
+
[--purge] -- Also removes .dockerize.yml
|
133
135
|
|
134
136
|
docker_info, info - Shows Docker information
|
135
137
|
docker_pull, pull - Pulls base Docker images (ruby, mysql/postgres)
|
136
138
|
docker_build, build - Builds Docker images
|
139
|
+
[--log] -- Displays/Streams build log
|
140
|
+
[--rebuild] -- Deletes images if exists and rebuilds
|
141
|
+
[--force] -- Force Image deletion. Works only with --rebuild option
|
142
|
+
|
137
143
|
docker_start, start - Run/Starts Docker containers
|
138
144
|
docker_stop, stop - Stops Docker containers
|
139
|
-
[--delete] --
|
145
|
+
[--delete] -- Also deletes the containers
|
140
146
|
|
141
147
|
docker_delete, delete - Deletes Docker containers
|
142
148
|
help, h - Prints this message</code></pre>
|
@@ -175,7 +181,7 @@ src="https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Feendroro
|
|
175
181
|
</div></div>
|
176
182
|
|
177
183
|
<div id="footer">
|
178
|
-
Generated on Sat Aug 12
|
184
|
+
Generated on Sat Aug 12 16:08:38 2017 by
|
179
185
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
180
186
|
0.9.9 (ruby-2.1.0).
|
181
187
|
</div>
|
data/docs/index.html
CHANGED
@@ -114,8 +114,10 @@ dock configure $ bundle exec dock configure --tiny $ bundle exec dock
|
|
114
114
|
dockerize $ bundle exec dock dockerize --test-env $ bundle exec dock
|
115
115
|
undockerize $ bundle exec dock undockerize --purge $ bundle exec dock
|
116
116
|
docker_info $ bundle exec dock docker_pull $ bundle exec dock docker_build
|
117
|
-
$ bundle exec dock
|
118
|
-
exec dock
|
117
|
+
$ bundle exec dock docker_build --log $ bundle exec dock docker_build
|
118
|
+
--rebuild $ bundle exec dock docker_build --rebuild --force $ bundle exec
|
119
|
+
dock docker_start $ bundle exec dock docker_stop $ bundle exec dock
|
120
|
+
docker_stop --delete $ bundle exec dock docker_delete </code></p>
|
119
121
|
|
120
122
|
<p>Help message: “` Usage: dock <command> or: bundle exec dock
|
121
123
|
<command></p>
|
@@ -123,20 +125,24 @@ exec dock docker_stop --delete </code></p>
|
|
123
125
|
<p>commands:</p>
|
124
126
|
|
125
127
|
<pre class="code ruby"><code class="ruby"> configure, c, rc, cr - Generates '.dockerize.yml'
|
126
|
-
[--tiny] --
|
128
|
+
[--tiny] -- Generates shorter config file, skipping all descriptions
|
127
129
|
|
128
130
|
dockerize, dc, d - Generates docker config files
|
129
|
-
[--test-env] --
|
131
|
+
[--test-env] -- Generates configurations to run tests.
|
130
132
|
|
131
133
|
undockerize, ud, du, u, dd - Removes docker configurations
|
132
|
-
[--purge] --
|
134
|
+
[--purge] -- Also removes .dockerize.yml
|
133
135
|
|
134
136
|
docker_info, info - Shows Docker information
|
135
137
|
docker_pull, pull - Pulls base Docker images (ruby, mysql/postgres)
|
136
138
|
docker_build, build - Builds Docker images
|
139
|
+
[--log] -- Displays/Streams build log
|
140
|
+
[--rebuild] -- Deletes images if exists and rebuilds
|
141
|
+
[--force] -- Force Image deletion. Works only with --rebuild option
|
142
|
+
|
137
143
|
docker_start, start - Run/Starts Docker containers
|
138
144
|
docker_stop, stop - Stops Docker containers
|
139
|
-
[--delete] --
|
145
|
+
[--delete] -- Also deletes the containers
|
140
146
|
|
141
147
|
docker_delete, delete - Deletes Docker containers
|
142
148
|
help, h - Prints this message</code></pre>
|
@@ -175,7 +181,7 @@ src="https://app.fossa.io/api/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Feendroro
|
|
175
181
|
</div></div>
|
176
182
|
|
177
183
|
<div id="footer">
|
178
|
-
Generated on Sat Aug 12
|
184
|
+
Generated on Sat Aug 12 16:08:37 2017 by
|
179
185
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
180
186
|
0.9.9 (ruby-2.1.0).
|
181
187
|
</div>
|
@@ -102,7 +102,7 @@
|
|
102
102
|
</div>
|
103
103
|
|
104
104
|
<div id="footer">
|
105
|
-
Generated on Sat Aug 12
|
105
|
+
Generated on Sat Aug 12 16:08:38 2017 by
|
106
106
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
107
107
|
0.9.9 (ruby-2.1.0).
|
108
108
|
</div>
|
@@ -2,8 +2,6 @@ module DockerizeRails
|
|
2
2
|
module CommandLineMethods
|
3
3
|
require 'colorize'
|
4
4
|
|
5
|
-
# rubocop:disable Metrics/MethodLength
|
6
|
-
# rubocop:disable Metrics/AbcSize
|
7
5
|
def self.invoke(options)
|
8
6
|
DRNameSpace.add_hash options[1][:args]
|
9
7
|
commands = Helpers.processed_commands
|
@@ -32,8 +30,6 @@ module DockerizeRails
|
|
32
30
|
return help 1
|
33
31
|
end
|
34
32
|
end
|
35
|
-
# rubocop:enable Metrics/MethodLength
|
36
|
-
# rubocop:enable Metrics/AbcSize
|
37
33
|
|
38
34
|
def self.dockerize
|
39
35
|
Helpers.ensure_rails_root
|
@@ -21,21 +21,21 @@ module DockerizeRails
|
|
21
21
|
aliases: %I[configure c rc cr],
|
22
22
|
help: "Generates '#{CONFIG_FILE_NAME}'".freeze,
|
23
23
|
params: {
|
24
|
-
:'--tiny' => '
|
24
|
+
:'--tiny' => 'Generates shorter config file, skipping all descriptions'.freeze
|
25
25
|
}
|
26
26
|
},
|
27
27
|
dockerize: {
|
28
28
|
aliases: %I[dockerize dc d],
|
29
29
|
help: 'Generates docker config files'.freeze,
|
30
30
|
params: {
|
31
|
-
:'--test-env' => '
|
31
|
+
:'--test-env' => 'Generates configurations to run tests.'.freeze
|
32
32
|
}
|
33
33
|
},
|
34
34
|
undockerize: {
|
35
35
|
aliases: %I[undockerize ud du u dd],
|
36
36
|
help: 'Removes docker configurations'.freeze,
|
37
37
|
params: {
|
38
|
-
:'--purge' => "
|
38
|
+
:'--purge' => "Also removes #{CONFIG_FILE_NAME}".freeze
|
39
39
|
}
|
40
40
|
},
|
41
41
|
docker_info: {
|
@@ -48,7 +48,12 @@ module DockerizeRails
|
|
48
48
|
},
|
49
49
|
docker_build: {
|
50
50
|
aliases: %I[docker_build build],
|
51
|
-
help: 'Builds Docker images'.freeze
|
51
|
+
help: 'Builds Docker images'.freeze,
|
52
|
+
params: {
|
53
|
+
:'--log' => 'Displays/Streams build log'.freeze,
|
54
|
+
:'--rebuild' => 'Deletes images if exists and rebuilds'.freeze,
|
55
|
+
:'--force' => 'Force Image deletion. Works only with --rebuild option'.freeze
|
56
|
+
}
|
52
57
|
},
|
53
58
|
docker_start: {
|
54
59
|
aliases: %I[docker_start start],
|
@@ -58,12 +63,15 @@ module DockerizeRails
|
|
58
63
|
aliases: %I[docker_stop stop],
|
59
64
|
help: 'Stops Docker containers'.freeze,
|
60
65
|
params: {
|
61
|
-
|
66
|
+
:'--delete' => 'Also deletes the containers'.freeze
|
62
67
|
}
|
63
68
|
},
|
64
69
|
docker_delete: {
|
65
70
|
aliases: %I[docker_delete delete],
|
66
|
-
help: 'Deletes Docker containers'.freeze
|
71
|
+
help: 'Deletes Docker containers'.freeze,
|
72
|
+
params: {
|
73
|
+
:'--force' => 'Force Container deletion.'.freeze
|
74
|
+
}
|
67
75
|
},
|
68
76
|
help: {
|
69
77
|
aliases: %I[help h],
|
@@ -3,12 +3,18 @@ module DockerizeRails
|
|
3
3
|
module DockerBuild
|
4
4
|
def self.build_rails
|
5
5
|
if Docker::Image.exist? DockerHelpers.get_name(:rails, :image)
|
6
|
-
|
7
|
-
|
6
|
+
if DRNameSpace.namespace.rebuild
|
7
|
+
image = Docker::Image.get DockerHelpers.get_name(:rails, :image)
|
8
|
+
puts " ==> Removing Image: #{DockerHelpers.get_name(:rails, :image)}".blue
|
9
|
+
image.remove(force: DRNameSpace.namespace.force || false)
|
10
|
+
else
|
11
|
+
puts " ==> Image >#{DockerHelpers.get_name(:rails, :image)}< already exists".green
|
12
|
+
return 0
|
13
|
+
end
|
8
14
|
end
|
9
15
|
build_docker_image(
|
10
|
-
|
11
|
-
|
16
|
+
"#{Constants::CONFIG_DIRECTORY_NAME}/#{Constants::RAILS_DIRECTORY_NAME}/Dockerfile",
|
17
|
+
DockerHelpers.get_name(:rails, :image)
|
12
18
|
)
|
13
19
|
puts " ==> Image >#{DockerHelpers.get_name(:rails, :image)}< built successfully".green
|
14
20
|
0
|
@@ -22,12 +28,18 @@ module DockerizeRails
|
|
22
28
|
def self.build_mysql
|
23
29
|
if DRConfig.linked_database? && DRConfig.databases[DRConfig.application_env] == 'mysql'
|
24
30
|
if Docker::Image.exist? DockerHelpers.get_name(:mysql, :image)
|
25
|
-
|
26
|
-
|
31
|
+
if DRNameSpace.namespace.rebuild
|
32
|
+
image = Docker::Image.get DockerHelpers.get_name(:mysql, :image)
|
33
|
+
puts " ==> Removing Image: #{DockerHelpers.get_name(:mysql, :image)}".blue
|
34
|
+
image.remove(force: DRNameSpace.namespace.force || false)
|
35
|
+
else
|
36
|
+
puts " ==> Image >#{DockerHelpers.get_name(:mysql, :image)}< already exists".green
|
37
|
+
return 0
|
38
|
+
end
|
27
39
|
end
|
28
40
|
build_docker_image(
|
29
|
-
|
30
|
-
|
41
|
+
"#{Constants::CONFIG_DIRECTORY_NAME}/#{Constants::MYSQL_DIRECTORY_NAME}/Dockerfile",
|
42
|
+
DockerHelpers.get_name(:mysql, :image)
|
31
43
|
)
|
32
44
|
puts " ==> Image >#{DockerHelpers.get_name(:mysql, :image)}< built successfully".green
|
33
45
|
end
|
@@ -42,12 +54,18 @@ module DockerizeRails
|
|
42
54
|
def self.build_postgres
|
43
55
|
if DRConfig.linked_database? && DRConfig.databases[DRConfig.application_env] == 'postgresql'
|
44
56
|
if Docker::Image.exist? DockerHelpers.get_name(:postgres, :image)
|
45
|
-
|
46
|
-
|
57
|
+
if DRNameSpace.namespace.rebuild
|
58
|
+
image = Docker::Image.get DockerHelpers.get_name(:postgres, :image)
|
59
|
+
puts " ==> Removing Image: #{DockerHelpers.get_name(:postgres, :image)}".blue
|
60
|
+
image.remove(force: DRNameSpace.namespace.force || false)
|
61
|
+
else
|
62
|
+
puts " ==> Image >#{DockerHelpers.get_name(:postgres, :image)}< already exists".green
|
63
|
+
return 0
|
64
|
+
end
|
47
65
|
end
|
48
66
|
build_docker_image(
|
49
|
-
|
50
|
-
|
67
|
+
"#{Constants::CONFIG_DIRECTORY_NAME}/#{Constants::PG_DIRECTORY_NAME}/Dockerfile",
|
68
|
+
DockerHelpers.get_name(:postgres, :image)
|
51
69
|
)
|
52
70
|
puts " ==> Image >#{DockerHelpers.get_name(:postgres, :image)}< built successfully".green
|
53
71
|
end
|
@@ -60,13 +78,26 @@ module DockerizeRails
|
|
60
78
|
end
|
61
79
|
|
62
80
|
def self.build_docker_image(dockerfile, repo)
|
63
|
-
image = Docker::Image.build_from_dir(
|
64
|
-
|
65
|
-
|
66
|
-
|
81
|
+
image = Docker::Image.build_from_dir('.', dockerfile: dockerfile) do |output|
|
82
|
+
if DRNameSpace.namespace.stream_log
|
83
|
+
if (log = JSON.parse(output)) && log.key?('stream')
|
84
|
+
$stdout.puts log['stream']
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
67
88
|
image.tag(repo: repo, tag: DRConfig.application_env)
|
68
89
|
puts "Image '#{repo}:#{DRConfig.application_env}' build success".green
|
69
90
|
0
|
91
|
+
rescue Docker::Error::UnexpectedResponseError => _
|
92
|
+
puts
|
93
|
+
puts " ==> An error has occurred while building Image: #{repo}:#{DRConfig.application_env}".red
|
94
|
+
puts
|
95
|
+
1
|
96
|
+
rescue Excon::Error::Socket => exception
|
97
|
+
puts
|
98
|
+
puts exception.to_s.red
|
99
|
+
puts
|
100
|
+
1
|
70
101
|
rescue Docker::Error::NotFoundError => exception
|
71
102
|
puts
|
72
103
|
puts exception.to_s.red
|
@@ -22,13 +22,14 @@ module DockerizeRails
|
|
22
22
|
def self.docker_delete(container_name)
|
23
23
|
container = Docker::Container.get(container_name)
|
24
24
|
container.stop if container.info['State']['Running']
|
25
|
-
container.delete(:force
|
25
|
+
container.delete(force: DRNameSpace.namespace.force || false)
|
26
26
|
puts "Container >#{container_name}< deleted successfully.".green
|
27
27
|
0
|
28
28
|
rescue Docker::Error::NotFoundError => exception
|
29
29
|
puts exception.to_s.strip.red
|
30
30
|
1
|
31
31
|
end
|
32
|
+
|
32
33
|
class << self
|
33
34
|
private :docker_delete
|
34
35
|
end
|
@@ -35,15 +35,13 @@ module DockerizeRails
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
# rubocop:disable Metrics/AbcSize
|
39
|
-
# rubocop:disable Metrics/MethodLength
|
40
38
|
def self.build_options(definitions, service)
|
41
39
|
options = DockerOptions.new
|
42
40
|
options.image get_name(service, :image)
|
43
41
|
options.name get_name(service, :container)
|
44
42
|
options.hostname '0.0.0.0'
|
45
|
-
definitions['expose'].each {|expose| options.expose expose} if definitions.key?('expose')
|
46
|
-
definitions['environment'].each {|env| options.add_env env} if definitions.key?('environment')
|
43
|
+
definitions['expose'].each { |expose| options.expose expose } if definitions.key?('expose')
|
44
|
+
definitions['environment'].each { |env| options.add_env env } if definitions.key?('environment')
|
47
45
|
if definitions.key?('ports')
|
48
46
|
definitions['ports'].each do |ports|
|
49
47
|
options.add_port_binds(ports.split(':')[1], ports.split(':')[0])
|
@@ -56,8 +54,6 @@ module DockerizeRails
|
|
56
54
|
end
|
57
55
|
options.options
|
58
56
|
end
|
59
|
-
# rubocop:enable Metrics/AbcSize
|
60
|
-
# rubocop:enable Metrics/MethodLength
|
61
57
|
|
62
58
|
def self.print_version
|
63
59
|
docker_version = Docker.version
|
@@ -73,7 +69,7 @@ module DockerizeRails
|
|
73
69
|
Helpers.print_formatted_info('Experimental', "#{docker_version['Experimental']}\n")
|
74
70
|
Helpers.print_formatted_info(
|
75
71
|
'Build Time',
|
76
|
-
|
72
|
+
"#{DateTime.parse(docker_version['BuildTime']).strftime('%b %d, %Y %I:%M %p')}\n"
|
77
73
|
)
|
78
74
|
end
|
79
75
|
end
|
@@ -29,11 +29,11 @@ module DockerizeRails
|
|
29
29
|
|
30
30
|
def expose(port)
|
31
31
|
@options['ExposedPorts']["#{port}/tcp"] = {}
|
32
|
-
@options['HostConfig']['PortBindings']["#{port}/tcp"] = [{'HostPort' => port}]
|
32
|
+
@options['HostConfig']['PortBindings']["#{port}/tcp"] = [{ 'HostPort' => port }]
|
33
33
|
end
|
34
34
|
|
35
35
|
def add_port_binds(container, host)
|
36
|
-
@options['HostConfig']['PortBindings']["#{container}/tcp"] = [{'HostPort' => host}]
|
36
|
+
@options['HostConfig']['PortBindings']["#{container}/tcp"] = [{ 'HostPort' => host }]
|
37
37
|
end
|
38
38
|
|
39
39
|
def add_env(env)
|
@@ -45,13 +45,7 @@ module DockerizeRails
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def options
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def deep_copy(o)
|
54
|
-
Marshal.load(Marshal.dump(o))
|
48
|
+
Marshal.load(Marshal.dump(@options))
|
55
49
|
end
|
56
50
|
end
|
57
51
|
end
|
@@ -77,7 +77,6 @@ module DockerizeRails
|
|
77
77
|
container.start(options)
|
78
78
|
end
|
79
79
|
|
80
|
-
# rubocop:disable Metrics/AbcSize
|
81
80
|
def self.docker_start(definitions, service)
|
82
81
|
options = DockerHelpers.build_options(definitions, service)
|
83
82
|
container = Docker::Container.create options
|
@@ -95,7 +94,6 @@ module DockerizeRails
|
|
95
94
|
end
|
96
95
|
container.start binds
|
97
96
|
end
|
98
|
-
# rubocop:enable Metrics/AbcSize
|
99
97
|
|
100
98
|
class << self
|
101
99
|
private :docker_start
|
@@ -23,7 +23,7 @@ module DockerizeRails
|
|
23
23
|
container = Docker::Container.get(container_name)
|
24
24
|
if container.info['State']['Running']
|
25
25
|
container.stop
|
26
|
-
container.delete(:
|
26
|
+
container.delete(force: true) if DRNameSpace.namespace.delete_containers
|
27
27
|
puts "Container >#{container_name}< stopped successfully.".green
|
28
28
|
puts "Container >#{container_name}< deleted successfully.".green if DRNameSpace.namespace.delete_containers
|
29
29
|
else
|
@@ -46,7 +46,6 @@ module DockerizeRails
|
|
46
46
|
database_host_type == Constants::DATABASE_HOST_LINKED
|
47
47
|
end
|
48
48
|
|
49
|
-
# rubocop:disable Metrics/AbcSize
|
50
49
|
def self.to_yaml_str
|
51
50
|
"---
|
52
51
|
# Set application name
|
@@ -130,7 +129,6 @@ database_user_name: #{database_user_name}
|
|
130
129
|
database_user_pass: #{database_user_pass}
|
131
130
|
"
|
132
131
|
end
|
133
|
-
# rubocop:enable Metrics/AbcSize
|
134
132
|
|
135
133
|
def self.to_hash
|
136
134
|
Hash[ATTRIBUTES.map do |accessor|
|
@@ -16,6 +16,9 @@ module DockerizeRails
|
|
16
16
|
opts.on('--purge') { options[:purge] = true }
|
17
17
|
opts.on('--test-env') { options[:test_env] = true }
|
18
18
|
opts.on('--delete') { options[:delete_containers] = true }
|
19
|
+
opts.on('--log') { options[:stream_log] = true }
|
20
|
+
opts.on('--rebuild') { options[:rebuild] = true }
|
21
|
+
opts.on('--force') { options[:force] = true }
|
19
22
|
end
|
20
23
|
parser.parse!
|
21
24
|
[ARGV[0].to_s, args: options]
|