lucy_dockerunner 0.1.1 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -6
- data/Gemfile.lock +1 -11
- data/README.md +16 -1
- data/Rakefile +1 -1
- data/lib/lucy_dockerunner/version.rb +1 -1
- data/lib/lucy_dockerunner.rb +2 -3
- data/lib/rake/lucyd_hooks.rb +43 -0
- data/lib/tasks/compose.rake +7 -6
- data/lib/tasks/compose_assets.rake +33 -0
- data/lib/tasks/compose_db.rake +0 -1
- data/lib/tasks/compose_logs.rake +0 -1
- data/lib/tasks/compose_prod.rake +108 -109
- data/lib/tasks/compose_test.rake +0 -1
- data/lib/tasks/task_helpers/compose_taskhelper.rb +11 -7
- data/lib/tasks/task_helpers/taskhelper.rb +10 -9
- metadata +9 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4446f3dd1ecb3193d0868bd3247ffa451352bddee1cf81e5d8e9bf9aad3936cb
|
4
|
+
data.tar.gz: cc912d91c7691de292b7ea115a0fcada45871057d3a10e69132a088cdad5c294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e48250f0baca9e750660853c344d4cf99abf7e6290d12aebb2ea07955e1964076af66417bdb391cf719d7f337c989c23bc9879bf0c722ee88dc370306e7a41c
|
7
|
+
data.tar.gz: fd287ccf462d6017fc054ccf2e7075a6f17ccf871c24c4a29d60126adc8ab8394bd13462a0773dfb917584ad76649853354679b4705148365f92e7a97d22eb86
|
data/Gemfile
CHANGED
@@ -7,16 +7,11 @@ gemspec
|
|
7
7
|
|
8
8
|
gem "rake"
|
9
9
|
|
10
|
-
gem "rake-hooks", git: "https://github.com/JesusGautamah/rake-hooks.git", branch: "master"
|
11
|
-
|
12
10
|
group :test, :development do
|
13
11
|
gem "rspec", "~> 3.0"
|
14
12
|
gem "rubocop", "~> 1.21"
|
15
|
-
gem "rubocop-rspec", "~> 2.4"
|
16
13
|
gem "rubocop-performance", "~> 1.11"
|
17
14
|
gem "rubocop-rake", "~> 0.5"
|
15
|
+
gem "rubocop-rspec", "~> 2.4"
|
18
16
|
gem "simplecov", "~> 0.21"
|
19
17
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,7 @@
|
|
1
|
-
GIT
|
2
|
-
remote: https://github.com/JesusGautamah/rake-hooks.git
|
3
|
-
revision: eb7fb883a2718523ba55f41ae2ab6ba1df1e8e80
|
4
|
-
branch: master
|
5
|
-
specs:
|
6
|
-
rake-hooks (1.2.6)
|
7
|
-
rake
|
8
|
-
|
9
1
|
PATH
|
10
2
|
remote: .
|
11
3
|
specs:
|
12
|
-
lucy_dockerunner (0.1.
|
13
|
-
rake-hooks
|
4
|
+
lucy_dockerunner (0.1.5)
|
14
5
|
|
15
6
|
GEM
|
16
7
|
remote: https://rubygems.org/
|
@@ -76,7 +67,6 @@ PLATFORMS
|
|
76
67
|
DEPENDENCIES
|
77
68
|
lucy_dockerunner!
|
78
69
|
rake
|
79
|
-
rake-hooks!
|
80
70
|
rspec (~> 3.0)
|
81
71
|
rubocop (~> 1.21)
|
82
72
|
rubocop-performance (~> 1.11)
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# LucyDockerunner
|
2
2
|
|
3
|
-
Lucy Dockerunner is a Ruby gem that provides a simple wrapper around the Docker Compose CLI to make it easier to run Docker Compose commands from Ruby.
|
3
|
+
Lucy Dockerunner is a Ruby gem that provides a simple wrapper around the Docker Compose CLI to make it easier to run Docker Compose commands from Ruby On Rails projects.
|
4
4
|
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/lucy_dockerunner.svg)](https://badge.fury.io/rb/lucy_dockerunner)
|
6
6
|
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
@@ -8,6 +8,8 @@ Lucy Dockerunner is a Ruby gem that provides a simple wrapper around the Docker
|
|
8
8
|
|
9
9
|
Ruby version: >= 2.6.0
|
10
10
|
|
11
|
+
This gem version: 0.1.4
|
12
|
+
|
11
13
|
## Installation
|
12
14
|
|
13
15
|
You can install the gem by executing:
|
@@ -18,6 +20,15 @@ Or add it to your Gemfile:
|
|
18
20
|
|
19
21
|
gem 'lucy_dockerunner'
|
20
22
|
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
### Add the following code to your Rakefile to load the tasks
|
26
|
+
````ruby
|
27
|
+
require 'lucy_dockerunner'
|
28
|
+
|
29
|
+
LucyDockerunner.load_tasks
|
30
|
+
````
|
31
|
+
|
21
32
|
###### Docker actions
|
22
33
|
* `rake compose:install` - build docker compose and migrate the database
|
23
34
|
* `rake compose:build` - build docker compose services
|
@@ -75,6 +86,10 @@ $ rake compose:up
|
|
75
86
|
````
|
76
87
|
### Access the web service
|
77
88
|
http://localhost
|
89
|
+
|
90
|
+
|
91
|
+
## References
|
92
|
+
The code code inside the 'lib/rake/lucyd_hooks.rb' file is based on the code of the [rake-hooks](https://github.com/guillermo/rake-hooks) from Guillermo Iguaran, Joel Moss as described in the [Ruby Toolbox](https://www.ruby-toolbox.com/projects/rake-hooks) page.
|
78
93
|
## Contributing
|
79
94
|
|
80
95
|
Bug reports and pull requests are welcome on GitHub at https://github.com/JesusGautamah/lucy_dockerunner. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/JesusGautamah/lucy_dockerunner/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
data/lib/lucy_dockerunner.rb
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "lucy_dockerunner/version"
|
4
|
-
# require "rake/hooks"
|
5
4
|
|
5
|
+
# Main module
|
6
6
|
module LucyDockerunner
|
7
7
|
class Error < StandardError; end
|
8
|
-
|
9
8
|
class << self
|
10
9
|
def load_tasks
|
11
|
-
Dir[File.join(__dir__,
|
10
|
+
Dir[File.join(__dir__, "tasks", "*.rake")].each { |r| load r }
|
12
11
|
end
|
13
12
|
end
|
14
13
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Rake::LucydHooks from https://github.com/guillermo/rake-hooks, authors Guillermo Iguaran, Joel Moss
|
4
|
+
module Rake
|
5
|
+
module LucydHooks
|
6
|
+
def before(*task_names, &new_task)
|
7
|
+
task_names.each do |task_name|
|
8
|
+
old_task = Rake.application.instance_variable_get("@tasks").delete(task_name.to_s)
|
9
|
+
next unless old_task
|
10
|
+
|
11
|
+
desc old_task.full_comment if old_task.respond_to?(:full_comment)
|
12
|
+
task task_name => old_task.prerequisites do
|
13
|
+
new_task.call
|
14
|
+
old_task.invoke
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def after(*task_names, &new_task)
|
20
|
+
options = task_names.last.is_a?(Hash) ? task_names.pop : {}
|
21
|
+
ignore_exceptions = options.delete(:ignore_exceptions) || false
|
22
|
+
|
23
|
+
task_names.each do |task_name|
|
24
|
+
old_task = Rake.application.instance_variable_get("@tasks").delete(task_name.to_s)
|
25
|
+
next unless old_task
|
26
|
+
|
27
|
+
desc old_task.full_comment if old_task.respond_to?(:full_comment)
|
28
|
+
task task_name => old_task.prerequisites do
|
29
|
+
begin
|
30
|
+
old_task.invoke
|
31
|
+
rescue StandardError
|
32
|
+
raise unless ignore_exceptions
|
33
|
+
end
|
34
|
+
|
35
|
+
new_task.call
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
Rake::DSL.include Rake::LucydHooks if defined?(Rake::DSL)
|
43
|
+
include Rake::LucydHooks unless self.class.included_modules.include?(Rake::LucydHooks)
|
data/lib/tasks/compose.rake
CHANGED
@@ -2,18 +2,19 @@
|
|
2
2
|
|
3
3
|
require "rake"
|
4
4
|
require_relative "task_helpers/compose_taskhelper"
|
5
|
-
|
5
|
+
require_relative "../rake/lucyd_hooks"
|
6
6
|
|
7
7
|
def tasks_names
|
8
|
-
@tasks_names = %w[install build up down restart clean_all clean_volumes clean_orphans clean_images clean_networks
|
8
|
+
@tasks_names = %w[install build up down restart clean_all clean_volumes clean_orphans clean_images clean_networks
|
9
|
+
clean_stopped]
|
9
10
|
end
|
10
11
|
|
11
12
|
def namesp
|
12
|
-
@namesp =
|
13
|
+
@namesp = "compose"
|
13
14
|
end
|
14
15
|
|
15
16
|
def dev_compose_file
|
16
|
-
@dev_compose_file ||=
|
17
|
+
@dev_compose_file ||= "docker-compose.yml"
|
17
18
|
end
|
18
19
|
|
19
20
|
def task_helper
|
@@ -181,7 +182,7 @@ def compose_checker
|
|
181
182
|
end
|
182
183
|
|
183
184
|
def dockerfile_checker
|
184
|
-
!File.exist?(
|
185
|
+
!File.exist?("Dockerfile")
|
185
186
|
end
|
186
187
|
|
187
188
|
tasks_names.each do |task|
|
@@ -190,4 +191,4 @@ tasks_names.each do |task|
|
|
190
191
|
dockerfile_checker ? abort("Dockerfile not found.\nYou must have a Dockerfile file.") : nil
|
191
192
|
compose_checker ? (abort "Compose file not found.\nFor development, you must have a #{dev_compose_file} file.") : nil
|
192
193
|
end
|
193
|
-
end
|
194
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rake"
|
4
|
+
require_relative "task_helpers/compose_taskhelper"
|
5
|
+
require_relative "../rake/lucyd_hooks"
|
6
|
+
|
7
|
+
def task_helper
|
8
|
+
@task_helper ||= TaskHelpers::ComposeTaskhelper.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def compose_command
|
12
|
+
@compose_comand ||= task_helper.compose_command
|
13
|
+
end
|
14
|
+
|
15
|
+
namespace :compose_assets do
|
16
|
+
task :precompile do
|
17
|
+
puts "Precompiling Assets..."
|
18
|
+
system "sudo #{compose_command} run web rake assets:precompile"
|
19
|
+
puts "Precompiling Assets... Done!"
|
20
|
+
end
|
21
|
+
|
22
|
+
task :clean do
|
23
|
+
puts "Cleaning Assets..."
|
24
|
+
system "sudo #{compose_command} run web rake assets:clean"
|
25
|
+
puts "Cleaning Assets... Done!"
|
26
|
+
end
|
27
|
+
|
28
|
+
task :clobber do
|
29
|
+
puts "Clobbering Assets..."
|
30
|
+
system "sudo #{compose_command} run web rake assets:clobber"
|
31
|
+
puts "Clobbering Assets... Done!"
|
32
|
+
end
|
33
|
+
end
|
data/lib/tasks/compose_db.rake
CHANGED
data/lib/tasks/compose_logs.rake
CHANGED
data/lib/tasks/compose_prod.rake
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal:true
|
2
2
|
|
3
|
-
require
|
4
|
-
require_relative
|
5
|
-
|
3
|
+
require "rake"
|
4
|
+
require_relative "task_helpers/compose_taskhelper"
|
6
5
|
|
7
6
|
def tasks_names
|
8
|
-
@tasks_names = %w[install build up down restart clean_all clean_volumes clean_orphans clean_images clean_networks
|
7
|
+
@tasks_names = %w[install build up down restart clean_all clean_volumes clean_orphans clean_images clean_networks
|
8
|
+
clean_stopped]
|
9
9
|
end
|
10
10
|
|
11
11
|
def namesp
|
12
|
-
@namesp =
|
12
|
+
@namesp = "compose_prod"
|
13
13
|
end
|
14
14
|
|
15
15
|
def compose_file
|
16
|
-
@compose_file ||=
|
16
|
+
@compose_file ||= "docker-compose.prod.yml"
|
17
17
|
end
|
18
18
|
|
19
19
|
def task_helper
|
@@ -26,207 +26,208 @@ end
|
|
26
26
|
|
27
27
|
def ask(question)
|
28
28
|
puts question
|
29
|
-
|
29
|
+
$stdin.gets.chomp
|
30
30
|
end
|
31
31
|
|
32
32
|
namespace :compose_prod do
|
33
33
|
task :check_if_file_exists do
|
34
34
|
puts "Checking if docker-compose.prod.yml exists"
|
35
35
|
raise ComposeError unless File.exist?(file)
|
36
|
+
|
36
37
|
puts "Checking if docker-compose.prod.yml exists... Done!"
|
37
38
|
end
|
38
39
|
|
39
40
|
task :install do
|
40
41
|
puts "Installing Blockchain and Database Containers \nWARNING: This will delete all your data, and you are running this in production"
|
41
42
|
# ask in terminal if you want to continue
|
42
|
-
choice = ask(
|
43
|
-
if choice ==
|
44
|
-
puts
|
43
|
+
choice = ask("Are you sure you want to continue? (y/n)")
|
44
|
+
if choice == "y"
|
45
|
+
puts "Installing Blockchain and Database Containers"
|
45
46
|
system "sudo #{compose_command} -f docker-compose.prod.yml build"
|
46
|
-
puts
|
47
|
+
puts "Creating Database"
|
47
48
|
system "sudo #{compose_command} -f docker-compose.prod.yml run --rm web rails db:create"
|
48
|
-
puts
|
49
|
+
puts "Migrating Database"
|
49
50
|
system "sudo #{compose_command} -f docker-compose.prod.yml run --rm web rails db:migrate"
|
50
|
-
puts
|
51
|
+
puts "Seeding Database"
|
51
52
|
system "sudo #{compose_command} -f docker-compose.prod.yml run --rm web rails db:seed"
|
52
|
-
puts
|
53
|
+
puts "Stopping Containers"
|
53
54
|
system "sudo #{compose_command} -f docker-compose.prod.yml down"
|
54
|
-
puts
|
55
|
-
puts
|
56
|
-
puts
|
57
|
-
puts
|
58
|
-
puts
|
59
|
-
puts
|
60
|
-
puts
|
61
|
-
puts
|
62
|
-
puts
|
63
|
-
puts
|
64
|
-
puts
|
65
|
-
puts
|
66
|
-
puts
|
67
|
-
puts
|
68
|
-
puts
|
55
|
+
puts "Installing Blockchain and Database Containers... Done!"
|
56
|
+
puts "This already setup your database with some initial values"
|
57
|
+
puts "Start the containers with command: rake compose_prod:up"
|
58
|
+
puts "Stop the containers with command: rake compose_prod:down"
|
59
|
+
puts "Restart the containers with command: rake compose_prod:restart"
|
60
|
+
puts "Clean up the containers with command: rake compose_prod:clean_all"
|
61
|
+
puts "Build the containers againg with command: rake compose_prod:build"
|
62
|
+
puts "rake compose_db_prod command documentation at README.md to see database commands usage examples"
|
63
|
+
puts "See the production log files in Rails default logs folder when using compose_prod:up"
|
64
|
+
puts "Alternatively, you can use rake compose_prod_logs:all to see all logs"
|
65
|
+
puts "Read documentation for more compose_db_prod, compose_prod_logs, and compose_prod commands"
|
66
|
+
puts "-----------------------------------------------------------------------------------"
|
67
|
+
puts "Access the web server on port 80."
|
68
|
+
puts "http://localhost"
|
69
|
+
puts "Look at README.md for more details."
|
69
70
|
else
|
70
|
-
puts
|
71
|
+
puts "Installation cancelled"
|
71
72
|
end
|
72
|
-
puts
|
73
|
+
puts "-----------------------------------------------------------------------------------"
|
73
74
|
end
|
74
75
|
|
75
76
|
task :build do
|
76
77
|
puts "Building Compose... WARNING: you are running this in production"
|
77
78
|
# ask in terminal if you want to continue
|
78
|
-
choice = ask(
|
79
|
-
if choice ==
|
80
|
-
puts
|
79
|
+
choice = ask("Are you sure you want to continue? (y/n)")
|
80
|
+
if choice == "y"
|
81
|
+
puts "Building Compose..."
|
81
82
|
system "sudo #{compose_command} -f docker-compose.prod.yml build"
|
82
|
-
puts
|
83
|
+
puts "Building Compose... Done!"
|
83
84
|
else
|
84
|
-
puts
|
85
|
+
puts "Build cancelled"
|
85
86
|
end
|
86
|
-
puts
|
87
|
+
puts "-----------------------------------------------------------------------------------"
|
87
88
|
end
|
88
89
|
|
89
90
|
task :up do
|
90
|
-
puts
|
91
|
+
puts "Running Compose... WARNING: you are running this in production"
|
91
92
|
# ask in terminal if you want to continue
|
92
|
-
choice = ask(
|
93
|
-
if choice ==
|
94
|
-
puts
|
93
|
+
choice = ask("Are you sure you want to continue? (y/n)")
|
94
|
+
if choice == "y"
|
95
|
+
puts "Running Compose..."
|
95
96
|
system "sudo #{compose_command} -f docker-compose.prod.yml up -d --remove-orphans"
|
96
|
-
puts
|
97
|
+
puts "Running Compose... Done!"
|
97
98
|
else
|
98
|
-
puts
|
99
|
+
puts "Running cancelled"
|
99
100
|
end
|
100
|
-
puts
|
101
|
+
puts "-----------------------------------------------------------------------------------"
|
101
102
|
end
|
102
103
|
|
103
104
|
task :down do
|
104
|
-
puts
|
105
|
+
puts "Stopping Compose... WARNING: you are running this in production"
|
105
106
|
# ask in terminal if you want to continue
|
106
|
-
choice = ask(
|
107
|
-
if choice ==
|
108
|
-
puts
|
107
|
+
choice = ask("Are you sure you want to continue? (y/n)")
|
108
|
+
if choice == "y"
|
109
|
+
puts "Stopping Compose..."
|
109
110
|
system "sudo #{compose_command} -f docker-compose.prod.yml down"
|
110
|
-
puts
|
111
|
+
puts "Stopping Compose... Done!"
|
111
112
|
else
|
112
|
-
puts
|
113
|
+
puts "Stopping cancelled"
|
113
114
|
end
|
114
|
-
puts
|
115
|
+
puts "-----------------------------------------------------------------------------------"
|
115
116
|
end
|
116
117
|
|
117
118
|
task :restart do
|
118
|
-
puts
|
119
|
+
puts "Restarting Compose... WARNING: you are running this in production"
|
119
120
|
# ask in terminal if you want to continue
|
120
|
-
choice = ask(
|
121
|
-
if choice ==
|
122
|
-
puts
|
121
|
+
choice = ask("Are you sure you want to continue? (y/n)")
|
122
|
+
if choice == "y"
|
123
|
+
puts "Restarting Compose..."
|
123
124
|
system "sudo #{compose_command} -f docker-compose.prod.yml restart"
|
124
|
-
puts
|
125
|
+
puts "Restarting Compose... Done!"
|
125
126
|
else
|
126
|
-
puts
|
127
|
+
puts "Restarting cancelled"
|
127
128
|
end
|
128
|
-
puts
|
129
|
+
puts "-----------------------------------------------------------------------------------"
|
129
130
|
end
|
130
131
|
|
131
132
|
task :status do
|
132
|
-
puts
|
133
|
+
puts "Status of Compose... WARNING: you are running this in production"
|
133
134
|
# ask in terminal if you want to continue
|
134
|
-
choice = ask(
|
135
|
-
if choice ==
|
136
|
-
puts
|
135
|
+
choice = ask("Are you sure you want to continue? (y/n)")
|
136
|
+
if choice == "y"
|
137
|
+
puts "Status of Compose..."
|
137
138
|
system "sudo #{compose_command} -f docker-compose.prod.yml ps"
|
138
|
-
puts
|
139
|
+
puts "Status of Compose... Done!"
|
139
140
|
else
|
140
|
-
puts
|
141
|
+
puts "Status cancelled"
|
141
142
|
end
|
142
|
-
puts
|
143
|
+
puts "-----------------------------------------------------------------------------------"
|
143
144
|
end
|
144
145
|
|
145
146
|
task :shell do
|
146
|
-
puts
|
147
|
+
puts "Opening shell in Compose... WARNING: you are running this in production"
|
147
148
|
# ask in terminal if you want to continue
|
148
|
-
choice = ask(
|
149
|
-
if choice ==
|
150
|
-
puts
|
149
|
+
choice = ask("Are you sure you want to continue? (y/n)")
|
150
|
+
if choice == "y"
|
151
|
+
puts "Opening shell in Compose..."
|
151
152
|
system "sudo #{compose_command} -f docker-compose.prod.yml exec web bash"
|
152
|
-
puts
|
153
|
+
puts "Opening shell in Compose... Done!"
|
153
154
|
else
|
154
|
-
puts
|
155
|
+
puts "Opening shell cancelled"
|
155
156
|
end
|
156
|
-
puts
|
157
|
+
puts "-----------------------------------------------------------------------------------"
|
157
158
|
end
|
158
159
|
|
159
160
|
task :clean_all do
|
160
|
-
puts
|
161
|
+
puts "Cleaning Compose... WARNING: you are running this in production"
|
161
162
|
# ask in terminal if you want to continue
|
162
|
-
choice = ask(
|
163
|
-
if choice ==
|
164
|
-
puts
|
163
|
+
choice = ask("Are you sure you want to continue? (y/n)")
|
164
|
+
if choice == "y"
|
165
|
+
puts "Cleaning Compose..."
|
165
166
|
system "sudo #{compose_command} -f docker-compose.prod.yml down --volumes --remove-orphans"
|
166
|
-
puts
|
167
|
+
puts "Cleaning Compose... Done!"
|
167
168
|
else
|
168
|
-
puts
|
169
|
+
puts "Cleaning cancelled"
|
169
170
|
end
|
170
|
-
puts
|
171
|
+
puts "-----------------------------------------------------------------------------------"
|
171
172
|
end
|
172
173
|
|
173
174
|
task :clean_containers do
|
174
175
|
puts "Cleaning Containers... WARNING: you are running this in production"
|
175
176
|
# ask in terminal if you want to continue
|
176
|
-
choice = ask(
|
177
|
-
if choice ==
|
178
|
-
puts
|
177
|
+
choice = ask("Are you sure you want to continue? (y/n)")
|
178
|
+
if choice == "y"
|
179
|
+
puts "Stopping Containers"
|
179
180
|
system "sudo #{compose_command} -f docker-compose.prod.yml down"
|
180
|
-
puts
|
181
|
-
puts
|
181
|
+
puts "Stopping Containers... Done!"
|
182
|
+
puts "Cleaning Containers..."
|
182
183
|
system "sudo #{compose_command} -f docker-compose.prod.yml rm -f"
|
183
|
-
puts
|
184
|
+
puts "Cleaning Containers... Done!"
|
184
185
|
else
|
185
|
-
puts
|
186
|
+
puts "Cleaning cancelled"
|
186
187
|
end
|
187
|
-
puts
|
188
|
+
puts "-----------------------------------------------------------------------------------"
|
188
189
|
end
|
189
190
|
|
190
191
|
task :clean_images do
|
191
192
|
puts "Cleaning Images... WARNING: you are running this in production"
|
192
193
|
# ask in terminal if you want to continue
|
193
|
-
choice = ask(
|
194
|
-
if choice ==
|
195
|
-
puts
|
194
|
+
choice = ask("Are you sure you want to continue? (y/n)")
|
195
|
+
if choice == "y"
|
196
|
+
puts "Cleaning Images..."
|
196
197
|
system "sudo #{compose_command} -f docker-compose.prod.yml rmi -f"
|
197
|
-
puts
|
198
|
+
puts "Cleaning Images... Done!"
|
198
199
|
else
|
199
|
-
puts
|
200
|
+
puts "Cleaning cancelled"
|
200
201
|
end
|
201
|
-
puts
|
202
|
+
puts "-----------------------------------------------------------------------------------"
|
202
203
|
end
|
203
|
-
|
204
|
+
|
204
205
|
task :clean_volumes do
|
205
206
|
puts "Cleaning Volumes... WARNING: you are running this in production"
|
206
207
|
# ask in terminal if you want to continue
|
207
|
-
choice = ask(
|
208
|
-
if choice ==
|
209
|
-
puts
|
208
|
+
choice = ask("Are you sure you want to continue? (y/n)")
|
209
|
+
if choice == "y"
|
210
|
+
puts "Cleaning Volumes..."
|
210
211
|
system "sudo #{compose_command} -f docker-compose.prod.yml down --volumes"
|
211
|
-
puts
|
212
|
+
puts "Cleaning Volumes... Done!"
|
212
213
|
else
|
213
|
-
puts
|
214
|
+
puts "Cleaning cancelled"
|
214
215
|
end
|
215
|
-
puts
|
216
|
+
puts "-----------------------------------------------------------------------------------"
|
216
217
|
end
|
217
218
|
|
218
219
|
task :clean_orphans do
|
219
220
|
puts "Cleaning Orphans... WARNING: you are running this in production"
|
220
221
|
# ask in terminal if you want to continue
|
221
|
-
choice = ask(
|
222
|
-
if choice ==
|
223
|
-
puts
|
222
|
+
choice = ask("Are you sure you want to continue? (y/n)")
|
223
|
+
if choice == "y"
|
224
|
+
puts "Cleaning Orphans..."
|
224
225
|
system "sudo #{compose_command} -f docker-compose.prod.yml down --remove-orphans"
|
225
|
-
puts
|
226
|
+
puts "Cleaning Orphans... Done!"
|
226
227
|
else
|
227
|
-
puts
|
228
|
+
puts "Cleaning cancelled"
|
228
229
|
end
|
229
|
-
puts
|
230
|
+
puts "-----------------------------------------------------------------------------------"
|
230
231
|
end
|
231
232
|
end
|
232
233
|
|
@@ -235,7 +236,7 @@ def compose_checker
|
|
235
236
|
end
|
236
237
|
|
237
238
|
def dockerfile_checker
|
238
|
-
!File.exist?(
|
239
|
+
!File.exist?("Dockerfile")
|
239
240
|
end
|
240
241
|
|
241
242
|
tasks_names.each do |task|
|
@@ -245,5 +246,3 @@ tasks_names.each do |task|
|
|
245
246
|
compose_checker ? (abort "Compose file not found.\nFor development, you must have a #{compose_file} file.") : nil
|
246
247
|
end
|
247
248
|
end
|
248
|
-
|
249
|
-
|
data/lib/tasks/compose_test.rake
CHANGED
@@ -1,21 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "English"
|
3
4
|
require_relative "taskhelper"
|
4
5
|
|
6
|
+
module TaskHelpers
|
7
|
+
class ComposeTaskhelper < TaskHelpers::Taskhelper
|
8
|
+
def compose_command
|
9
|
+
@compose_comand ||= compose_command_finder
|
10
|
+
end
|
5
11
|
|
6
|
-
|
7
|
-
def compose_command
|
8
|
-
@compose_comand ||= compose_command_finder
|
9
|
-
end
|
12
|
+
private
|
10
13
|
|
11
|
-
private
|
12
14
|
def compose_command_finder
|
13
15
|
@command = ["docker compose", "docker-compose"]
|
14
16
|
@command.each do |command|
|
15
17
|
system "#{command} --version > /dev/null 2>&1"
|
16
|
-
return command if
|
17
|
-
|
18
|
+
return command if $CHILD_STATUS.success?
|
19
|
+
|
20
|
+
command = false unless $CHILD_STATUS.success?
|
18
21
|
end
|
19
22
|
raise ComposeError unless command == false
|
20
23
|
end
|
24
|
+
end
|
21
25
|
end
|
@@ -9,15 +9,16 @@ module TaskHelpers
|
|
9
9
|
end
|
10
10
|
|
11
11
|
private
|
12
|
-
def dev_error(e)
|
13
|
-
if env_acceptable?
|
14
|
-
puts "#{e.class}: #{e.message}"
|
15
|
-
puts e.backtrace
|
16
|
-
end
|
17
|
-
end
|
18
12
|
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
def dev_error(e)
|
14
|
+
return unless env_acceptable?
|
15
|
+
|
16
|
+
puts "#{e.class}: #{e.message}"
|
17
|
+
puts e.backtrace
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_acceptable?
|
21
|
+
Rails.env.development? || Rails.env.test?
|
22
|
+
end
|
22
23
|
end
|
23
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lucy_dockerunner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JesusGautamah
|
@@ -9,24 +9,11 @@ autorequire:
|
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2023-02-13 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
description: "This gem is a tool to run docker containers with rake commands, good
|
28
|
-
for CI/CD and Rails projects. \n It's a wrapper for docker-compose commands and
|
29
|
-
original code was developed \n by me in the project https://github.com/JesusGautamah/outerspace-blockchain"
|
12
|
+
dependencies: []
|
13
|
+
description: |-
|
14
|
+
This gem is a tool to run docker containers with rake commands, good for CI/CD and Rails projects.
|
15
|
+
It's a wrapper for docker-compose commands and original code was developed
|
16
|
+
by me in the project https://github.com/JesusGautamah/outerspace-blockchain
|
30
17
|
email:
|
31
18
|
- lima.jesuscc@gmail.com
|
32
19
|
executables: []
|
@@ -45,8 +32,10 @@ files:
|
|
45
32
|
- Rakefile
|
46
33
|
- lib/lucy_dockerunner.rb
|
47
34
|
- lib/lucy_dockerunner/version.rb
|
35
|
+
- lib/rake/lucyd_hooks.rb
|
48
36
|
- lib/tasks/.keep
|
49
37
|
- lib/tasks/compose.rake
|
38
|
+
- lib/tasks/compose_assets.rake
|
50
39
|
- lib/tasks/compose_db.rake
|
51
40
|
- lib/tasks/compose_logs.rake
|
52
41
|
- lib/tasks/compose_prod.rake
|
@@ -77,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
66
|
- !ruby/object:Gem::Version
|
78
67
|
version: '0'
|
79
68
|
requirements: []
|
80
|
-
rubygems_version: 3.
|
69
|
+
rubygems_version: 3.3.26
|
81
70
|
signing_key:
|
82
71
|
specification_version: 4
|
83
72
|
summary: This gem is a tool to run docker containers with rake commands, good for
|