lucy_dockerunner 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -1
- data/Gemfile.lock +1 -1
- data/README.md +59 -10
- data/lib/lucy_dockerunner/version.rb +1 -1
- data/lib/rake/lucyd_hooks.rb +6 -26
- data/lib/tasks/compose.rake +5 -3
- data/lib/tasks/compose_assets.rake +1 -1
- 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 +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7902c6fdd608e972b6025b32f6ef8731e37fa5e8249ef0446f0503ff450e184
|
4
|
+
data.tar.gz: ff2d987b86f299f91fe34060adfe93b07a00199f44cd3afdf730ce5347797878
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f530d7c039fc703c258e6c791a12367255c7ca4cc1d0ee2e5eda38f5ad5686c532889e4b3a11a4b9137c6a00b93ee78a8c4b78d82d03b8ea151421ce00ce947
|
7
|
+
data.tar.gz: 6b58db241568b140abff172148afef7bae3986357ed6dd7fe56abe4f354fdacc427072718332e2fe9751fc5628d8431ea7e09fbbc5b7a98c1100622ab34b1b94
|
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,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Lucy Dockerunner
|
2
2
|
|
3
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
|
|
@@ -8,8 +8,26 @@ 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.
|
11
|
+
This gem version: 0.1.7
|
12
12
|
|
13
|
+
## Dependencies
|
14
|
+
|
15
|
+
* [Docker](https://www.docker.com/)
|
16
|
+
* [Docker Compose](https://docs.docker.com/compose/)
|
17
|
+
* [Ruby On Rails](https://rubyonrails.org/) - or any other Ruby project that uses Docker Compose to run the project with specific services.
|
18
|
+
|
19
|
+
## Files
|
20
|
+
This gem uses the following files to run the docker compose services:
|
21
|
+
|
22
|
+
- Dockerfile
|
23
|
+
- docker-compose.yml - development
|
24
|
+
- docker-compose.prod.yml - production
|
25
|
+
|
26
|
+
It's important to have .env files separated by environment, for example:
|
27
|
+
- .env.development
|
28
|
+
- .env.production
|
29
|
+
|
30
|
+
And remember to add the .env files to the .gitignore file and reference them in the docker-compose.yml and docker-compose.prod.yml files.
|
13
31
|
## Installation
|
14
32
|
|
15
33
|
You can install the gem by executing:
|
@@ -29,7 +47,7 @@ require 'lucy_dockerunner'
|
|
29
47
|
LucyDockerunner.load_tasks
|
30
48
|
````
|
31
49
|
|
32
|
-
|
50
|
+
## Docker actions
|
33
51
|
* `rake compose:install` - build docker compose and migrate the database
|
34
52
|
* `rake compose:build` - build docker compose services
|
35
53
|
* `rake compose:up` - start the docker compose services
|
@@ -45,7 +63,26 @@ LucyDockerunner.load_tasks
|
|
45
63
|
* `rake compose:clean_volumes` - clean all docker compose volumes
|
46
64
|
* `rake compose:clean_orphans` - clean all docker compose orphans
|
47
65
|
* `rake compose:clean_containers` - clean all docker compose containers
|
48
|
-
|
66
|
+
|
67
|
+
## Docker Production actions
|
68
|
+
|
69
|
+
* `rake compose_prod:install` - build docker compose and migrate the database
|
70
|
+
* `rake compose_prod:build` - build docker compose services
|
71
|
+
* `rake compose_prod:up` - start the docker compose services
|
72
|
+
* `rake compose_prod:down` - stop the docker compose services
|
73
|
+
* `rake compose_prod:status` - show the status of the docker compose services
|
74
|
+
* `rake compose_prod:shell` - open a shell in the web service
|
75
|
+
* `rake compose_prod:db_detach` - detach the database from the docker compose services
|
76
|
+
* `rake compose_prod:redis_detach` - detach the redis from the docker compose services
|
77
|
+
* `rake compose_prod:back_detach` - detach the backend(redis, sidekiq, db) from the docker compose services
|
78
|
+
* `rake compose_prod:restart` - restart the docker compose services
|
79
|
+
* `rake compose_prod:clean_all` - clean all docker compose services
|
80
|
+
* `rake compose_prod:clean_images` - clean all docker compose images
|
81
|
+
* `rake compose_prod:clean_volumes` - clean all docker compose volumes
|
82
|
+
* `rake compose_prod:clean_orphans` - clean all docker compose orphans
|
83
|
+
* `rake compose_prod:clean_containers` - clean all docker compose containers
|
84
|
+
|
85
|
+
## Database actions
|
49
86
|
* `rake compose_db:migrate` - migrate the database
|
50
87
|
* `rake compose_db:reset` - reset the database
|
51
88
|
* `rake compose_db:drop` - drop the database
|
@@ -57,7 +94,7 @@ LucyDockerunner.load_tasks
|
|
57
94
|
* `rake compose_db:reset_setup` - drop and setup the database
|
58
95
|
* `rake compose_db:reset` - reset the database
|
59
96
|
|
60
|
-
|
97
|
+
## Tests actions
|
61
98
|
* `rake compose_test:all` - run all tests
|
62
99
|
* `rake compose_test:clean_all` - run all tests after cleaning docker compose services
|
63
100
|
* `rake compose_test:controllers` - run controllers tests
|
@@ -68,7 +105,7 @@ LucyDockerunner.load_tasks
|
|
68
105
|
* `rake compose_test:routing` - run routing tests
|
69
106
|
* `rake compose_test:views` - run views tests
|
70
107
|
|
71
|
-
|
108
|
+
## LOGS actions
|
72
109
|
* `rake compose_logs:web` - show web logs
|
73
110
|
* `rake compose_logs:db` - show db logs
|
74
111
|
* `rake compose_logs:redis` - show redis logs
|
@@ -80,13 +117,16 @@ LucyDockerunner.load_tasks
|
|
80
117
|
* `rake compose_logs:tail_sidekiq` - tail sidekiq logs
|
81
118
|
* `rake compose_logs:tail_all` - tail all logs
|
82
119
|
|
120
|
+
## Assets actions
|
121
|
+
* `rake compose_assets:precompile` - precompile assets
|
122
|
+
* `rake compose_assets:clean` - clean assets
|
123
|
+
* `rake compose_assets:clobber` - clobber assets
|
124
|
+
|
125
|
+
|
83
126
|
## Start the docker compose services
|
84
127
|
````bash
|
85
128
|
$ rake compose:up
|
86
129
|
````
|
87
|
-
### Access the web service
|
88
|
-
http://localhost
|
89
|
-
|
90
130
|
|
91
131
|
## References
|
92
132
|
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.
|
@@ -94,10 +134,19 @@ The code code inside the 'lib/rake/lucyd_hooks.rb' file is based on the code of
|
|
94
134
|
|
95
135
|
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).
|
96
136
|
|
137
|
+
|
138
|
+
## [![Repography logo](https://images.repography.com/logo.svg)](https://repography.com) / Recent activity [![Time period](https://images.repography.com/33522702/JesusGautamah/lucy_dockerunner/recent-activity/7YfytFwl78FgWgAtJeO7jReo0y6GD6YPifcYNBxOxaE/yhI9H3pCZlEkfuvJLU9LC32UBu1c8k5toFvgUDmttdM_badge.svg)](https://repography.com)
|
139
|
+
[![Timeline graph](https://images.repography.com/33522702/JesusGautamah/lucy_dockerunner/recent-activity/7YfytFwl78FgWgAtJeO7jReo0y6GD6YPifcYNBxOxaE/yhI9H3pCZlEkfuvJLU9LC32UBu1c8k5toFvgUDmttdM_timeline.svg)](https://github.com/JesusGautamah/lucy_dockerunner/commits)
|
140
|
+
[![Issue status graph](https://images.repography.com/33522702/JesusGautamah/lucy_dockerunner/recent-activity/7YfytFwl78FgWgAtJeO7jReo0y6GD6YPifcYNBxOxaE/yhI9H3pCZlEkfuvJLU9LC32UBu1c8k5toFvgUDmttdM_issues.svg)](https://github.com/JesusGautamah/lucy_dockerunner/issues)
|
141
|
+
[![Pull request status graph](https://images.repography.com/33522702/JesusGautamah/lucy_dockerunner/recent-activity/7YfytFwl78FgWgAtJeO7jReo0y6GD6YPifcYNBxOxaE/yhI9H3pCZlEkfuvJLU9LC32UBu1c8k5toFvgUDmttdM_prs.svg)](https://github.com/JesusGautamah/lucy_dockerunner/pulls)
|
142
|
+
[![Top contributors](https://images.repography.com/33522702/JesusGautamah/lucy_dockerunner/recent-activity/7YfytFwl78FgWgAtJeO7jReo0y6GD6YPifcYNBxOxaE/yhI9H3pCZlEkfuvJLU9LC32UBu1c8k5toFvgUDmttdM_users.svg)](https://github.com/JesusGautamah/lucy_dockerunner/graphs/contributors)
|
143
|
+
|
144
|
+
|
145
|
+
|
97
146
|
## License
|
98
147
|
|
99
148
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
100
149
|
|
101
150
|
## Code of Conduct
|
102
151
|
|
103
|
-
Everyone interacting in the LucyDockerunner project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/JesusGautamah/lucy_dockerunner/blob/master/CODE_OF_CONDUCT.md).
|
152
|
+
Everyone interacting in the LucyDockerunner project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/JesusGautamah/lucy_dockerunner/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/rake/lucyd_hooks.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# from https://github.com/guillermo/rake-hooks, authors Guillermo Iguaran, Joel Moss
|
4
4
|
module Rake
|
5
|
+
# module Rake::Hooks
|
5
6
|
module LucydHooks
|
6
|
-
def
|
7
|
+
def bef(*task_names, &new_task)
|
7
8
|
task_names.each do |task_name|
|
8
9
|
old_task = Rake.application.instance_variable_get("@tasks").delete(task_name.to_s)
|
9
10
|
next unless old_task
|
@@ -15,29 +16,8 @@ module Rake
|
|
15
16
|
end
|
16
17
|
end
|
17
18
|
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
19
|
end
|
40
|
-
end
|
41
20
|
|
42
|
-
Rake::DSL.include Rake::LucydHooks if defined?(Rake::DSL)
|
43
|
-
include Rake::LucydHooks unless self.class.included_modules.include?(Rake::LucydHooks)
|
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
@@ -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
|
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,19 +1,18 @@
|
|
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.7
|
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.
|
15
|
-
|
16
|
-
by me in the project https://github.com/JesusGautamah/outerspace-blockchain
|
15
|
+
Docs: https://github.com/JesusGautamah/lucy_dockerunner
|
17
16
|
email:
|
18
17
|
- lima.jesuscc@gmail.com
|
19
18
|
executables: []
|
@@ -51,6 +50,7 @@ metadata:
|
|
51
50
|
homepage_uri: https://github.com/JesusGautamah/lucy_dockerunner
|
52
51
|
source_code_uri: https://github.com/JesusGautamah/lucy_dockerunner
|
53
52
|
changelog_uri: https://github.com/JesusGautamah/lucy_dockerunner/blob/master/CHANGELOG.md
|
53
|
+
rubygems_mfa_required: 'true'
|
54
54
|
post_install_message:
|
55
55
|
rdoc_options: []
|
56
56
|
require_paths:
|
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
|
-
rubygems_version: 3.
|
69
|
+
rubygems_version: 3.4.1
|
70
70
|
signing_key:
|
71
71
|
specification_version: 4
|
72
72
|
summary: This gem is a tool to run docker containers with rake commands, good for
|