lucy_dockerunner 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -1
- data/Gemfile.lock +1 -1
- data/README.md +13 -2
- data/lib/lucy_dockerunner/version.rb +1 -1
- data/lib/rake/lucyd_hooks.rb +23 -0
- data/lib/tasks/compose.rake +6 -4
- data/lib/tasks/compose_assets.rake +33 -0
- data/lib/tasks/compose_db.rake +1 -1
- data/lib/tasks/compose_logs.rake +1 -1
- data/lib/tasks/compose_prod.rake +7 -4
- data/lib/tasks/compose_test.rake +1 -1
- data/lib/tasks/task_helpers/compose_taskhelper.rb +4 -3
- data/lib/tasks/task_helpers/taskhelper.rb +7 -4
- metadata +6 -4
- data/lib/rake/hooks.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed51fadc53b795aa23350c7ce49b87d25234cee22ed9a65d310815077f5b8972
|
4
|
+
data.tar.gz: ca61bacb4fc54f6432ddb5bca8167343881410ac2ae4eb7198c824dd91c5d20d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a4f5083d80a651b373d23cac7edead9f248defe9a2590c8653ed3f9bfc63094ed8dc8ba6d12f6bf1c107bd816442398bcf18b88164fe96657377cbdf03a9e6e
|
7
|
+
data.tar.gz: c9be619deded43389003507a4c2893cb602be2fd35511c2c6873c00ca36a6d9f20c4d24ec05b630f1104d3544b653f3805d3a7d36b0f54c96469cc5b922fedd3
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
AllCops:
|
2
2
|
TargetRubyVersion: 2.6
|
3
|
+
SuggestExtensions: false
|
4
|
+
NewCops: enable
|
3
5
|
|
4
6
|
Style/StringLiterals:
|
5
7
|
Enabled: true
|
@@ -10,4 +12,9 @@ Style/StringLiteralsInInterpolation:
|
|
10
12
|
EnforcedStyle: double_quotes
|
11
13
|
|
12
14
|
Layout/LineLength:
|
13
|
-
Max:
|
15
|
+
Max: 180
|
16
|
+
|
17
|
+
Metrics/BlockLength:
|
18
|
+
Exclude:
|
19
|
+
- 'spec/**/*'
|
20
|
+
- 'lib/tasks/**/*'
|
data/Gemfile.lock
CHANGED
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
|
[](https://badge.fury.io/rb/lucy_dockerunner)
|
6
6
|
[](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
|
@@ -78,7 +89,7 @@ http://localhost
|
|
78
89
|
|
79
90
|
|
80
91
|
## References
|
81
|
-
The code code inside the 'lib/rake/
|
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.
|
82
93
|
## Contributing
|
83
94
|
|
84
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).
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# from https://github.com/guillermo/rake-hooks, authors Guillermo Iguaran, Joel Moss
|
4
|
+
module Rake
|
5
|
+
# module Rake::Hooks
|
6
|
+
module LucydHooks
|
7
|
+
def bef(*task_names, &new_task)
|
8
|
+
task_names.each do |task_name|
|
9
|
+
old_task = Rake.application.instance_variable_get("@tasks").delete(task_name.to_s)
|
10
|
+
next unless old_task
|
11
|
+
|
12
|
+
desc old_task.full_comment if old_task.respond_to?(:full_comment)
|
13
|
+
task task_name => old_task.prerequisites do
|
14
|
+
new_task.call
|
15
|
+
old_task.invoke
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Rake::DSL.include Rake::LucydHooks if defined?(Rake::DSL)
|
22
|
+
include Rake::LucydHooks unless self.class.included_modules.include?(Rake::LucydHooks)
|
23
|
+
end
|
data/lib/tasks/compose.rake
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "rake"
|
4
4
|
require_relative "task_helpers/compose_taskhelper"
|
5
|
-
require_relative "../rake/
|
5
|
+
require_relative "../rake/lucyd_hooks"
|
6
6
|
|
7
7
|
def tasks_names
|
8
8
|
@tasks_names = %w[install build up down restart clean_all clean_volumes clean_orphans clean_images clean_networks
|
@@ -187,8 +187,10 @@ end
|
|
187
187
|
|
188
188
|
tasks_names.each do |task|
|
189
189
|
before_action = "#{namesp}:#{task}"
|
190
|
-
|
191
|
-
|
192
|
-
|
190
|
+
bef before_action do
|
191
|
+
docker_abort_error = "Dockerfile not found.\nYou must have a Dockerfile file."
|
192
|
+
compose_abort_error = "Compose file not found.\nFor development, you must have a #{dev_compose_file} file."
|
193
|
+
dockerfile_checker ? abort(docker_abort_error) : puts("Dockerfile found.")
|
194
|
+
compose_checker ? abort(compose_abort_error) : puts("Compose file found.")
|
193
195
|
end
|
194
196
|
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_command ||= 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
@@ -38,7 +38,8 @@ namespace :compose_prod do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
task :install do
|
41
|
-
puts "Installing Blockchain and Database Containers \
|
41
|
+
puts "Installing Blockchain and Database Containers \n
|
42
|
+
WARNING: This will delete all your data, and you are running this in production"
|
42
43
|
# ask in terminal if you want to continue
|
43
44
|
choice = ask("Are you sure you want to continue? (y/n)")
|
44
45
|
if choice == "y"
|
@@ -241,8 +242,10 @@ end
|
|
241
242
|
|
242
243
|
tasks_names.each do |task|
|
243
244
|
before_action = "#{namesp}:#{task}"
|
244
|
-
|
245
|
-
|
246
|
-
|
245
|
+
bef before_action do
|
246
|
+
docker_abort_error = "Dockerfile not found.\nYou must have a Dockerfile file."
|
247
|
+
compose_abort_error = "Compose file not found.\nYou must have a docker-compose.prod.yml file."
|
248
|
+
dockerfile_checker ? abort(docker_abort_error) : puts("Dockerfile found")
|
249
|
+
compose_checker ? abort(compose_abort_error) : puts("Compose Production file found")
|
247
250
|
end
|
248
251
|
end
|
data/lib/tasks/compose_test.rake
CHANGED
@@ -4,9 +4,10 @@ require "English"
|
|
4
4
|
require_relative "taskhelper"
|
5
5
|
|
6
6
|
module TaskHelpers
|
7
|
+
# ComposeTaskhelper
|
7
8
|
class ComposeTaskhelper < TaskHelpers::Taskhelper
|
8
9
|
def compose_command
|
9
|
-
@
|
10
|
+
@compose_command ||= compose_command_finder
|
10
11
|
end
|
11
12
|
|
12
13
|
private
|
@@ -17,9 +18,9 @@ module TaskHelpers
|
|
17
18
|
system "#{command} --version > /dev/null 2>&1"
|
18
19
|
return command if $CHILD_STATUS.success?
|
19
20
|
|
20
|
-
command = false
|
21
|
+
command = false
|
22
|
+
raise ComposeError if command == false
|
21
23
|
end
|
22
|
-
raise ComposeError unless command == false
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module TaskHelpers
|
4
|
+
# Taskhelper
|
4
5
|
class Taskhelper
|
6
|
+
# Compose Error
|
5
7
|
class ComposeError < StandardError
|
6
8
|
def initialize(message = "Docker Compose is not installed")
|
7
9
|
super
|
@@ -10,15 +12,16 @@ module TaskHelpers
|
|
10
12
|
|
11
13
|
private
|
12
14
|
|
13
|
-
def dev_error(
|
15
|
+
def dev_error(error)
|
14
16
|
return unless env_acceptable?
|
15
17
|
|
16
|
-
puts "#{
|
17
|
-
puts
|
18
|
+
puts "#{error.class}: #{error.message}"
|
19
|
+
puts error.backtrace
|
18
20
|
end
|
19
21
|
|
20
22
|
def env_acceptable?
|
21
|
-
Rails.env.development? || Rails.env.test?
|
23
|
+
# Rails.env.development? || Rails.env.test?
|
24
|
+
true
|
22
25
|
end
|
23
26
|
end
|
24
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JesusGautamah
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
This gem is a tool to run docker containers with rake commands, good for CI/CD and Rails projects.
|
@@ -32,9 +32,10 @@ files:
|
|
32
32
|
- Rakefile
|
33
33
|
- lib/lucy_dockerunner.rb
|
34
34
|
- lib/lucy_dockerunner/version.rb
|
35
|
-
- lib/rake/
|
35
|
+
- lib/rake/lucyd_hooks.rb
|
36
36
|
- lib/tasks/.keep
|
37
37
|
- lib/tasks/compose.rake
|
38
|
+
- lib/tasks/compose_assets.rake
|
38
39
|
- lib/tasks/compose_db.rake
|
39
40
|
- lib/tasks/compose_logs.rake
|
40
41
|
- lib/tasks/compose_prod.rake
|
@@ -50,6 +51,7 @@ metadata:
|
|
50
51
|
homepage_uri: https://github.com/JesusGautamah/lucy_dockerunner
|
51
52
|
source_code_uri: https://github.com/JesusGautamah/lucy_dockerunner
|
52
53
|
changelog_uri: https://github.com/JesusGautamah/lucy_dockerunner/blob/master/CHANGELOG.md
|
54
|
+
rubygems_mfa_required: 'true'
|
53
55
|
post_install_message:
|
54
56
|
rdoc_options: []
|
55
57
|
require_paths:
|
@@ -65,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
67
|
- !ruby/object:Gem::Version
|
66
68
|
version: '0'
|
67
69
|
requirements: []
|
68
|
-
rubygems_version: 3.
|
70
|
+
rubygems_version: 3.4.1
|
69
71
|
signing_key:
|
70
72
|
specification_version: 4
|
71
73
|
summary: This gem is a tool to run docker containers with rake commands, good for
|
data/lib/rake/hooks.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Rake::Hooks from https://github.com/guillermo/rake-hooks, authors Guillermo Iguaran, Joel Moss
|
4
|
-
module Rake
|
5
|
-
module Hooks
|
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::Hooks if defined?(Rake::DSL)
|
43
|
-
include Rake::Hooks unless self.class.included_modules.include?(Rake::Hooks)
|