lucy_dockerunner 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +88 -0
- data/LICENSE.txt +21 -0
- data/README.md +81 -0
- data/Rakefile +14 -0
- data/lib/lucy_dockerunner/version.rb +5 -0
- data/lib/lucy_dockerunner.rb +14 -0
- data/lib/tasks/.keep +0 -0
- data/lib/tasks/compose.rake +181 -0
- data/lib/tasks/compose_db.rake +81 -0
- data/lib/tasks/compose_logs.rake +105 -0
- data/lib/tasks/compose_prod.rake +221 -0
- data/lib/tasks/compose_test.rake +72 -0
- data/lib/tasks/task_helpers/compose_taskhelper.rb +21 -0
- data/lib/tasks/task_helpers/taskhelper.rb +23 -0
- data/sig/lucy_dockerunner.rbs +4 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f5e5a03a9ef72ac78d552d8f4961132d292f72bf10e3fe0aa9a0b8e3aca17f5a
|
4
|
+
data.tar.gz: dd65c50f4cd8f8f44f2f8090c591a307e7e57550bd642319afed5bc2afd46d94
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 179f532102d570dcbf439046f3bdc19c861fa99919d13ec47f43b8aca8504e417631aed62fad9935aef600abf0e5d3e2f7faf20895237c40f5774981205a2568
|
7
|
+
data.tar.gz: 6e3487f0144a3ddd385bece9540094cb6d4679868c7f4ee18cfca96b8cd31297a680df8ac82a05161aab3df689584414f4114bdaf3d0ef6cf04589f1e03ce459
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at lima.jesuscc@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in lucy_dockerunner.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "rake"
|
9
|
+
|
10
|
+
gem "rake-hooks", git: "https://github.com/JesusGautamah/rake-hooks.git", branch: "master"
|
11
|
+
|
12
|
+
group :test, :development do
|
13
|
+
gem "rspec", "~> 3.0"
|
14
|
+
gem "rubocop", "~> 1.21"
|
15
|
+
gem "rubocop-rspec", "~> 2.4"
|
16
|
+
gem "rubocop-performance", "~> 1.11"
|
17
|
+
gem "rubocop-rake", "~> 0.5"
|
18
|
+
gem "simplecov", "~> 0.21"
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/JesusGautamah/rake-hooks.git
|
3
|
+
revision: 4ee50e368c9cbc0ecb087df0ffdfdf1c647739c8
|
4
|
+
branch: master
|
5
|
+
specs:
|
6
|
+
rake-hooks (1.2.5)
|
7
|
+
rake
|
8
|
+
|
9
|
+
PATH
|
10
|
+
remote: .
|
11
|
+
specs:
|
12
|
+
lucy_dockerunner (0.1.8)
|
13
|
+
rake-hooks
|
14
|
+
|
15
|
+
GEM
|
16
|
+
remote: https://rubygems.org/
|
17
|
+
specs:
|
18
|
+
ast (2.4.2)
|
19
|
+
diff-lcs (1.5.0)
|
20
|
+
docile (1.4.0)
|
21
|
+
json (2.6.3)
|
22
|
+
parallel (1.22.1)
|
23
|
+
parser (3.2.1.0)
|
24
|
+
ast (~> 2.4.1)
|
25
|
+
rainbow (3.1.1)
|
26
|
+
rake (13.0.6)
|
27
|
+
regexp_parser (2.7.0)
|
28
|
+
rexml (3.2.5)
|
29
|
+
rspec (3.12.0)
|
30
|
+
rspec-core (~> 3.12.0)
|
31
|
+
rspec-expectations (~> 3.12.0)
|
32
|
+
rspec-mocks (~> 3.12.0)
|
33
|
+
rspec-core (3.12.1)
|
34
|
+
rspec-support (~> 3.12.0)
|
35
|
+
rspec-expectations (3.12.2)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.12.0)
|
38
|
+
rspec-mocks (3.12.3)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.12.0)
|
41
|
+
rspec-support (3.12.0)
|
42
|
+
rubocop (1.45.1)
|
43
|
+
json (~> 2.3)
|
44
|
+
parallel (~> 1.10)
|
45
|
+
parser (>= 3.2.0.0)
|
46
|
+
rainbow (>= 2.2.2, < 4.0)
|
47
|
+
regexp_parser (>= 1.8, < 3.0)
|
48
|
+
rexml (>= 3.2.5, < 4.0)
|
49
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
50
|
+
ruby-progressbar (~> 1.7)
|
51
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
52
|
+
rubocop-ast (1.26.0)
|
53
|
+
parser (>= 3.2.1.0)
|
54
|
+
rubocop-capybara (2.17.0)
|
55
|
+
rubocop (~> 1.41)
|
56
|
+
rubocop-performance (1.16.0)
|
57
|
+
rubocop (>= 1.7.0, < 2.0)
|
58
|
+
rubocop-ast (>= 0.4.0)
|
59
|
+
rubocop-rake (0.6.0)
|
60
|
+
rubocop (~> 1.0)
|
61
|
+
rubocop-rspec (2.18.1)
|
62
|
+
rubocop (~> 1.33)
|
63
|
+
rubocop-capybara (~> 2.17)
|
64
|
+
ruby-progressbar (1.11.0)
|
65
|
+
simplecov (0.22.0)
|
66
|
+
docile (~> 1.1)
|
67
|
+
simplecov-html (~> 0.11)
|
68
|
+
simplecov_json_formatter (~> 0.1)
|
69
|
+
simplecov-html (0.12.3)
|
70
|
+
simplecov_json_formatter (0.1.4)
|
71
|
+
unicode-display_width (2.4.2)
|
72
|
+
|
73
|
+
PLATFORMS
|
74
|
+
x86_64-linux
|
75
|
+
|
76
|
+
DEPENDENCIES
|
77
|
+
lucy_dockerunner!
|
78
|
+
rake
|
79
|
+
rake-hooks!
|
80
|
+
rspec (~> 3.0)
|
81
|
+
rubocop (~> 1.21)
|
82
|
+
rubocop-performance (~> 1.11)
|
83
|
+
rubocop-rake (~> 0.5)
|
84
|
+
rubocop-rspec (~> 2.4)
|
85
|
+
simplecov (~> 0.21)
|
86
|
+
|
87
|
+
BUNDLED WITH
|
88
|
+
2.4.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 JesusGautamah
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# LucyDockerunner
|
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.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
You can install the gem by executing:
|
8
|
+
|
9
|
+
$ gem install lucy_dockerunner
|
10
|
+
|
11
|
+
Or add it to your Gemfile:
|
12
|
+
|
13
|
+
gem 'lucy_dockerunner'
|
14
|
+
|
15
|
+
###### Docker actions
|
16
|
+
* `rake compose:install` - build docker compose and migrate the database
|
17
|
+
* `rake compose:build` - build docker compose services
|
18
|
+
* `rake compose:up` - start the docker compose services
|
19
|
+
* `rake compose:down` - stop the docker compose services
|
20
|
+
* `rake compose:db_detach` - detach the database from the docker compose services
|
21
|
+
* `rake compose:redis_detach` - detach the redis from the docker compose services
|
22
|
+
* `rake compose:back_detach` - detach the backend(redis, sidekiq, db) from the docker compose services
|
23
|
+
* `rake compose:restart` - restart the docker compose services
|
24
|
+
* `rake compose:clean_all` - clean all docker compose services
|
25
|
+
#### Database actions
|
26
|
+
* `rake compose_db:migrate` - migrate the database
|
27
|
+
* `rake compose_db:reset` - reset the database
|
28
|
+
* `rake compose_db:drop` - drop the database
|
29
|
+
* `rake compose_db:create` - create the database
|
30
|
+
* `rake compose_db:seed` - seed the database
|
31
|
+
* `rake compose_db:rollback` - rollback the database
|
32
|
+
* `rake compose_db:setup` - setup the database
|
33
|
+
* `rake compose_db:complete_setup` - complete setup the database
|
34
|
+
* `rake compose_db:reset_setup` - drop and setup the database
|
35
|
+
* `rake compose_db:reset` - reset the database
|
36
|
+
|
37
|
+
### Tests actions
|
38
|
+
* `rake compose_test:all` - run all tests
|
39
|
+
* `rake compose_test:clean_all` - run all tests after cleaning docker compose services
|
40
|
+
* `rake compose_test:controllers` - run controllers tests
|
41
|
+
* `rake compose_test:models` - run models tests
|
42
|
+
* `rake compose_test:requests` - run requests tests
|
43
|
+
* `rake compose_test:helpers` - run helpers tests
|
44
|
+
* `rake compose_test:mailers` - run mailers tests
|
45
|
+
* `rake compose_test:routing` - run routing tests
|
46
|
+
* `rake compose_test:views` - run views tests
|
47
|
+
|
48
|
+
### LOGS actions
|
49
|
+
* `rake compose_logs:web` - show web logs
|
50
|
+
* `rake compose_logs:db` - show db logs
|
51
|
+
* `rake compose_logs:redis` - show redis logs
|
52
|
+
* `rake compose_logs:sidekiq` - show sidekiq logs
|
53
|
+
* `rake compose_logs:all` - show all logs
|
54
|
+
* `rake compose_logs:tail_web` - tail web logs
|
55
|
+
* `rake compose_logs:tail_db` - tail db logs
|
56
|
+
* `rake compose_logs:tail_redis` - tail redis logs
|
57
|
+
* `rake compose_logs:tail_sidekiq` - tail sidekiq logs
|
58
|
+
* `rake compose_logs:tail_all` - tail all logs
|
59
|
+
* `rake compose_logs:follow_web` - follow web logs
|
60
|
+
* `rake compose_logs:follow_db` - follow db logs
|
61
|
+
* `rake compose_logs:follow_redis` - follow redis logs
|
62
|
+
* `rake compose_logs:follow_sidekiq` - follow sidekiq logs
|
63
|
+
* `rake compose_logs:follow_all` - follow all logs
|
64
|
+
|
65
|
+
## Start the blockchain
|
66
|
+
````bash
|
67
|
+
$ rake compose:up
|
68
|
+
````
|
69
|
+
### Access the blockchain web interface
|
70
|
+
http://localhost
|
71
|
+
## Contributing
|
72
|
+
|
73
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/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/[USERNAME]/lucy_dockerunner/blob/master/CODE_OF_CONDUCT.md).
|
74
|
+
|
75
|
+
## License
|
76
|
+
|
77
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
78
|
+
|
79
|
+
## Code of Conduct
|
80
|
+
|
81
|
+
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/[USERNAME]/lucy_dockerunner/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
require "rubocop/rake_task"
|
9
|
+
|
10
|
+
RuboCop::RakeTask.new
|
11
|
+
|
12
|
+
task default: %i[spec rubocop]
|
13
|
+
|
14
|
+
Dir.glob("lib/tasks/*.rake").each { |r| import r }
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lucy_dockerunner/version"
|
4
|
+
# require "rake/hooks"
|
5
|
+
|
6
|
+
module LucyDockerunner
|
7
|
+
class Error < StandardError; end
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def load_tasks
|
11
|
+
Dir[File.join(__dir__, 'tasks', '*.rake')].each { |r| load r }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/tasks/.keep
ADDED
File without changes
|
@@ -0,0 +1,181 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rake"
|
4
|
+
require_relative "task_helpers/compose_taskhelper"
|
5
|
+
require "rake/hooks"
|
6
|
+
|
7
|
+
def tasks_names
|
8
|
+
@tasks_names = %w[install build up down restart clean_all clean_volumes clean_orphans clean_images clean_networks clean_stopped]
|
9
|
+
end
|
10
|
+
|
11
|
+
def namesp
|
12
|
+
@namesp = 'compose'
|
13
|
+
end
|
14
|
+
|
15
|
+
def dev_compose_file
|
16
|
+
@dev_compose_file ||= 'docker-compose.yml'
|
17
|
+
end
|
18
|
+
|
19
|
+
def task_helper
|
20
|
+
@task_helper ||= TaskHelpers::ComposeTaskhelper.new
|
21
|
+
end
|
22
|
+
|
23
|
+
def compose_command
|
24
|
+
@compose_command ||= task_helper.compose_command
|
25
|
+
end
|
26
|
+
|
27
|
+
namespace :compose do
|
28
|
+
task :install do
|
29
|
+
puts "Installing Blockchain and Database Containers"
|
30
|
+
system "sudo #{compose_command} build"
|
31
|
+
puts "Creating Database"
|
32
|
+
system "sudo #{compose_command} run --rm web rails db:create"
|
33
|
+
puts "Migrating Database"
|
34
|
+
system "sudo #{compose_command} run --rm web rails db:migrate"
|
35
|
+
puts "Seeding Database"
|
36
|
+
system "sudo #{compose_command} run --rm web rails db:seed"
|
37
|
+
puts "Stopping Containers"
|
38
|
+
system "sudo #{compose_command} down"
|
39
|
+
puts "Installing Blockchain and Database Containers... Done!"
|
40
|
+
puts "This already setup your database with some initial values"
|
41
|
+
puts "Start the containers with command: rake compose:up"
|
42
|
+
puts "Stop the containers with command: rake compose:down"
|
43
|
+
puts "Restart the containers with command: rake compose:restart"
|
44
|
+
puts "Clean up the containers with command: rake compose:clean_all"
|
45
|
+
puts "Test your containers with command: rake compose:test"
|
46
|
+
puts "Build the containers againg with command: rake compose:build"
|
47
|
+
puts "rake compose_db command documentation at README.md to see database commands usage examples"
|
48
|
+
puts "See the development and test log files in Rails default logs folder when using compose:up"
|
49
|
+
puts "-----------------------------------------------------------------------------------"
|
50
|
+
puts "Access the web server on port 80."
|
51
|
+
puts "http://localhost"
|
52
|
+
puts "Look at README.md for more details."
|
53
|
+
end
|
54
|
+
|
55
|
+
task :build do
|
56
|
+
puts "Building Compose..."
|
57
|
+
system "sudo #{compose_command} build"
|
58
|
+
puts "Building Compose... Done!"
|
59
|
+
end
|
60
|
+
|
61
|
+
task :up do
|
62
|
+
puts compose_command
|
63
|
+
puts "Running Compose..."
|
64
|
+
system "sudo #{compose_command} up -d --remove-orphans"
|
65
|
+
puts "Running Compose... Done!"
|
66
|
+
end
|
67
|
+
|
68
|
+
task :down do
|
69
|
+
puts "Stopping Compose..."
|
70
|
+
system "sudo #{compose_command} down"
|
71
|
+
puts "Stopping Compose... Done!"
|
72
|
+
end
|
73
|
+
|
74
|
+
task :db_detach do
|
75
|
+
puts "Running Database Detached..."
|
76
|
+
system "sudo #{compose_command} up -d db"
|
77
|
+
puts "Running Database Detached... Done!"
|
78
|
+
end
|
79
|
+
|
80
|
+
task :redis_detach do
|
81
|
+
puts "Running Redis Detached..."
|
82
|
+
system "sudo #{compose_command} up -d redis"
|
83
|
+
puts "Running Redis Detached... Done!"
|
84
|
+
end
|
85
|
+
|
86
|
+
task :back_detach do
|
87
|
+
puts "Running Backend Detached..."
|
88
|
+
system "sudo #{compose_command} up -d --remove-orphans db redis sidekiq"
|
89
|
+
puts "Running Backend Detached... Done!"
|
90
|
+
end
|
91
|
+
|
92
|
+
task :restart do
|
93
|
+
puts "Restarting Compose..."
|
94
|
+
puts "Stopping Compose..."
|
95
|
+
system "sudo #{compose_command} down"
|
96
|
+
puts "Stopping Compose... Done!"
|
97
|
+
puts "Running Compose..."
|
98
|
+
system "sudo #{compose_command} up -d --remove-orphans"
|
99
|
+
puts "Restarting Compose... Done!"
|
100
|
+
end
|
101
|
+
|
102
|
+
task :clean_all do
|
103
|
+
puts "Cleaning Compose..."
|
104
|
+
puts "Stopping Compose..."
|
105
|
+
system "sudo #{compose_command} down"
|
106
|
+
puts "Stopping Compose... Done!"
|
107
|
+
puts "Removing Containers..."
|
108
|
+
system "sudo #{compose_command} rm -f"
|
109
|
+
puts "Removing Containers... Done!"
|
110
|
+
puts "Removing Images..."
|
111
|
+
system "sudo #{compose_command} rmi -f"
|
112
|
+
puts "Removing Images... Done!"
|
113
|
+
puts "Removing Volumes..."
|
114
|
+
system "sudo #{compose_command} down -v"
|
115
|
+
puts "Removing Volumes... Done!"
|
116
|
+
puts "Removing Orphans..."
|
117
|
+
system "sudo #{compose_command} down --remove-orphans"
|
118
|
+
puts "Removing Networks... Done!"
|
119
|
+
puts "Cleaning Compose... Done!"
|
120
|
+
end
|
121
|
+
|
122
|
+
task :clean_containers do
|
123
|
+
puts "Cleaning Containers..."
|
124
|
+
puts "Stopping Compose..."
|
125
|
+
system "sudo #{compose_command} down"
|
126
|
+
puts "Stopping Compose... Done!"
|
127
|
+
puts "Removing Containers..."
|
128
|
+
system "sudo #{compose_command} rm -f"
|
129
|
+
puts "Removing Containers... Done!"
|
130
|
+
puts "Cleaning Containers... Done!"
|
131
|
+
end
|
132
|
+
|
133
|
+
task :clean_images do
|
134
|
+
puts "Cleaning Images..."
|
135
|
+
puts "Stopping Compose..."
|
136
|
+
system "sudo #{compose_command} down"
|
137
|
+
puts "Stopping Compose... Done!"
|
138
|
+
puts "Removing Images..."
|
139
|
+
system "sudo #{compose_command} rmi -f"
|
140
|
+
puts "Removing Images... Done!"
|
141
|
+
puts "Cleaning Images... Done!"
|
142
|
+
end
|
143
|
+
|
144
|
+
task :clean_volumes do
|
145
|
+
puts "Cleaning Volumes..."
|
146
|
+
puts "Stopping Compose..."
|
147
|
+
system "sudo #{compose_command} down"
|
148
|
+
puts "Stopping Compose... Done!"
|
149
|
+
puts "Removing Volumes..."
|
150
|
+
system "sudo #{compose_command} down -v"
|
151
|
+
puts "Removing Volumes... Done!"
|
152
|
+
puts "Cleaning Volumes... Done!"
|
153
|
+
end
|
154
|
+
|
155
|
+
task :clean_orphans do
|
156
|
+
puts "Cleaning Networks..."
|
157
|
+
puts "Stopping Compose..."
|
158
|
+
system "sudo #{compose_command} down"
|
159
|
+
puts "Stopping Compose... Done!"
|
160
|
+
puts "Removing Networks..."
|
161
|
+
system "sudo #{compose_command} down --remove-orphans"
|
162
|
+
puts "Removing Networks... Done!"
|
163
|
+
puts "Cleaning Networks... Done!"
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def compose_checker
|
168
|
+
!File.exist?(compose_file)
|
169
|
+
end
|
170
|
+
|
171
|
+
def dockerfile_checker
|
172
|
+
!File.exist?('Dockerfile')
|
173
|
+
end
|
174
|
+
|
175
|
+
tasks_names.each do |task|
|
176
|
+
before_action = "#{namesp}:#{task}"
|
177
|
+
before before_action do
|
178
|
+
dockerfile_checker ? abort("Dockerfile not found.\nYou must have a Dockerfile file.") : nil
|
179
|
+
compose_checker ? (abort "Compose file not found.\nFor development, you must have a #{dev_compose_file} file.") : nil
|
180
|
+
end
|
181
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rake"
|
4
|
+
require_relative "task_helpers/compose_taskhelper"
|
5
|
+
require "rake/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_db do
|
16
|
+
task :drop do
|
17
|
+
puts "Dropping Database..."
|
18
|
+
system "sudo #{compose_command} run --rm web rake db:drop"
|
19
|
+
puts "Dropping Database... Done!"
|
20
|
+
end
|
21
|
+
|
22
|
+
task :rollback do
|
23
|
+
puts "Rolling Back Database..."
|
24
|
+
system "sudo #{compose_command} run --rm web rails db:rollback"
|
25
|
+
puts "Rolling Back Database... Done!"
|
26
|
+
end
|
27
|
+
|
28
|
+
task :complete_setup do
|
29
|
+
puts "Setting up Database..."
|
30
|
+
system "sudo #{compose_command} run --rm web rake db:create"
|
31
|
+
system "sudo #{compose_command} run --rm web rake db:migrate"
|
32
|
+
system "sudo #{compose_command} run --rm web rake db:seed"
|
33
|
+
puts "Setting up Database... Done!"
|
34
|
+
end
|
35
|
+
|
36
|
+
task :setup do
|
37
|
+
puts "Setting up and seeding Database..."
|
38
|
+
system "sudo #{compose_command} run --rm web rake db:setup"
|
39
|
+
puts "Setting up and seeding Database... Done!"
|
40
|
+
end
|
41
|
+
|
42
|
+
task :create do
|
43
|
+
puts "Creating Database..."
|
44
|
+
system "sudo #{compose_command} run --rm web rake db:create"
|
45
|
+
puts "Creating Database... Done!"
|
46
|
+
end
|
47
|
+
|
48
|
+
task :migrate do
|
49
|
+
puts "Running Migration..."
|
50
|
+
system "sudo #{compose_command} run --rm web rake db:migrate"
|
51
|
+
puts "Running Migration... Done!"
|
52
|
+
end
|
53
|
+
|
54
|
+
task :seed do
|
55
|
+
puts "Running Seed..."
|
56
|
+
system "sudo #{compose_command} run --rm web rake db:seed"
|
57
|
+
puts "Running Seed... Done!"
|
58
|
+
end
|
59
|
+
|
60
|
+
task :reset_setup do
|
61
|
+
puts "Resettting Database..."
|
62
|
+
system "sudo #{compose_command} run --rm web rake db:drop"
|
63
|
+
system "sudo #{compose_command} run --rm web rake db:setup"
|
64
|
+
puts "Resetting up Database... Done!"
|
65
|
+
end
|
66
|
+
|
67
|
+
task :reset do
|
68
|
+
puts "Resetting Database..."
|
69
|
+
system "sudo #{compose_command} run --rm web rake db:drop"
|
70
|
+
system "sudo #{compose_command} run --rm web rake db:create"
|
71
|
+
system "sudo #{compose_command} run --rm web rake db:migrate"
|
72
|
+
system "sudo #{compose_command} run --rm web rake db:seed"
|
73
|
+
puts "Resetting Compose... Done!"
|
74
|
+
end
|
75
|
+
|
76
|
+
task :force_reset do
|
77
|
+
puts "Running Compose Down"
|
78
|
+
system "rake compose:down"
|
79
|
+
system "rake compose_db:reset"
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rake"
|
4
|
+
require_relative "task_helpers/compose_taskhelper"
|
5
|
+
|
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_logs do
|
16
|
+
task :web do
|
17
|
+
puts "Showing Web Logs..."
|
18
|
+
system "sudo #{compose_command} logs web"
|
19
|
+
puts "Showing Web Logs... Done!"
|
20
|
+
end
|
21
|
+
|
22
|
+
task :db do
|
23
|
+
puts "Showing Database Logs..."
|
24
|
+
system "sudo #{compose_command} logs db"
|
25
|
+
puts "Showing Database Logs... Done!"
|
26
|
+
end
|
27
|
+
|
28
|
+
task :redis do
|
29
|
+
puts "Showing Redis Logs..."
|
30
|
+
system "sudo #{compose_command} logs redis"
|
31
|
+
puts "Showing Redis Logs... Done!"
|
32
|
+
end
|
33
|
+
|
34
|
+
task :sidekiq do
|
35
|
+
puts "Showing Sidekiq Logs..."
|
36
|
+
system "sudo #{compose_command} logs sidekiq"
|
37
|
+
puts "Showing Sidekiq Logs... Done!"
|
38
|
+
end
|
39
|
+
|
40
|
+
task :all do
|
41
|
+
puts "Showing All Logs..."
|
42
|
+
system "sudo #{compose_command} logs"
|
43
|
+
puts "Showing All Logs... Done!"
|
44
|
+
end
|
45
|
+
|
46
|
+
task :tail_web do
|
47
|
+
puts "Tailing Web Logs..."
|
48
|
+
system "sudo #{compose_command} logs -f web"
|
49
|
+
puts "Tailing Web Logs... Done!"
|
50
|
+
end
|
51
|
+
|
52
|
+
task :tail_db do
|
53
|
+
puts "Tailing Database Logs..."
|
54
|
+
system "sudo #{compose_command} logs -f db"
|
55
|
+
puts "Tailing Database Logs... Done!"
|
56
|
+
end
|
57
|
+
|
58
|
+
task :tail_redis do
|
59
|
+
puts "Tailing Redis Logs..."
|
60
|
+
system "sudo #{compose_command} logs -f redis"
|
61
|
+
puts "Tailing Redis Logs... Done!"
|
62
|
+
end
|
63
|
+
|
64
|
+
task :tail_sidekiq do
|
65
|
+
puts "Tailing Sidekiq Logs..."
|
66
|
+
system "sudo #{compose_command} logs -f sidekiq"
|
67
|
+
puts "Tailing Sidekiq Logs... Done!"
|
68
|
+
end
|
69
|
+
|
70
|
+
task :tail_all do
|
71
|
+
puts "Tailing All Logs..."
|
72
|
+
system "sudo #{compose_command} logs -f"
|
73
|
+
puts "Tailing All Logs... Done!"
|
74
|
+
end
|
75
|
+
|
76
|
+
task :follow_web do
|
77
|
+
puts "Following Web Logs..."
|
78
|
+
system "sudo #{compose_command} logs -f web"
|
79
|
+
puts "Following Web Logs... Done!"
|
80
|
+
end
|
81
|
+
|
82
|
+
task :follow_db do
|
83
|
+
puts "Following Database Logs..."
|
84
|
+
system "sudo #{compose_command} logs -f db"
|
85
|
+
puts "Following Database Logs... Done!"
|
86
|
+
end
|
87
|
+
|
88
|
+
task :follow_redis do
|
89
|
+
puts "Following Redis Logs..."
|
90
|
+
system "sudo #{compose_command} logs -f redis"
|
91
|
+
puts "Following Redis Logs... Done!"
|
92
|
+
end
|
93
|
+
|
94
|
+
task :follow_sidekiq do
|
95
|
+
puts "Following Sidekiq Logs..."
|
96
|
+
system "sudo #{compose_command} logs -f sidekiq"
|
97
|
+
puts "Following Sidekiq Logs... Done!"
|
98
|
+
end
|
99
|
+
|
100
|
+
task :follow_all do
|
101
|
+
puts "Following All Logs..."
|
102
|
+
system "sudo #{compose_command} logs -f"
|
103
|
+
puts "Following All Logs... Done!"
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,221 @@
|
|
1
|
+
# frozen_string_literal:true
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require_relative 'task_helpers/compose_taskhelper'
|
5
|
+
|
6
|
+
|
7
|
+
def tasks_names
|
8
|
+
@tasks_names = %w[install build up down restart clean_all clean_volumes clean_orphans clean_images clean_networks clean_stopped]
|
9
|
+
end
|
10
|
+
|
11
|
+
def namesp
|
12
|
+
@namesp = 'compose_prod'
|
13
|
+
end
|
14
|
+
|
15
|
+
def compose_file
|
16
|
+
@compose_file ||= 'docker-compose.prod.yml'
|
17
|
+
end
|
18
|
+
|
19
|
+
def task_helper
|
20
|
+
@task_helper ||= TaskHelpers::ComposeTaskhelper.new
|
21
|
+
end
|
22
|
+
|
23
|
+
def compose_command
|
24
|
+
@compose_command ||= task_helper.compose_command
|
25
|
+
end
|
26
|
+
|
27
|
+
def ask(question)
|
28
|
+
puts question
|
29
|
+
STDIN.gets.chomp
|
30
|
+
end
|
31
|
+
|
32
|
+
namespace :compose_prod do
|
33
|
+
task :check_if_file_exists do
|
34
|
+
puts "Checking if docker-compose.prod.yml exists"
|
35
|
+
raise ComposeError unless File.exist?(file)
|
36
|
+
puts "Checking if docker-compose.prod.yml exists... Done!"
|
37
|
+
end
|
38
|
+
|
39
|
+
task :install do
|
40
|
+
puts "Installing Blockchain and Database Containers \nWARNING: This will delete all your data, and you are running this in production"
|
41
|
+
# ask in terminal if you want to continue
|
42
|
+
choice = ask('Are you sure you want to continue? (y/n)')
|
43
|
+
if choice == 'y'
|
44
|
+
puts 'Installing Blockchain and Database Containers'
|
45
|
+
system "sudo #{compose_command} -f docker-compose.prod.yml build"
|
46
|
+
puts 'Creating Database'
|
47
|
+
system "sudo #{compose_command} -f docker-compose.prod.yml run --rm web rails db:create"
|
48
|
+
puts 'Migrating Database'
|
49
|
+
system "sudo #{compose_command} -f docker-compose.prod.yml run --rm web rails db:migrate"
|
50
|
+
puts 'Seeding Database'
|
51
|
+
system "sudo #{compose_command} -f docker-compose.prod.yml run --rm web rails db:seed"
|
52
|
+
puts 'Stopping Containers'
|
53
|
+
system "sudo #{compose_command} -f docker-compose.prod.yml down"
|
54
|
+
puts 'Installing Blockchain and Database Containers... Done!'
|
55
|
+
puts 'This already setup your database with some initial values'
|
56
|
+
puts 'Start the containers with command: rake compose_prod:up'
|
57
|
+
puts 'Stop the containers with command: rake compose_prod:down'
|
58
|
+
puts 'Restart the containers with command: rake compose_prod:restart'
|
59
|
+
puts 'Clean up the containers with command: rake compose_prod:clean_all'
|
60
|
+
puts 'Build the containers againg with command: rake compose_prod:build'
|
61
|
+
puts 'rake compose_db_prod command documentation at README.md to see database commands usage examples'
|
62
|
+
puts 'See the production log files in Rails default logs folder when using compose_prod:up'
|
63
|
+
puts 'Alternatively, you can use rake compose_prod_logs:all to see all logs'
|
64
|
+
puts 'Read documentation for more compose_db_prod, compose_prod_logs, and compose_prod commands'
|
65
|
+
puts '-----------------------------------------------------------------------------------'
|
66
|
+
puts 'Access the web server on port 80.'
|
67
|
+
puts 'http://localhost'
|
68
|
+
puts 'Look at README.md for more details.'
|
69
|
+
else
|
70
|
+
puts 'Installation cancelled'
|
71
|
+
end
|
72
|
+
puts '-----------------------------------------------------------------------------------'
|
73
|
+
end
|
74
|
+
|
75
|
+
task :build do
|
76
|
+
puts "Building Compose... WARNING: you are running this in production"
|
77
|
+
# ask in terminal if you want to continue
|
78
|
+
choice = ask('Are you sure you want to continue? (y/n)')
|
79
|
+
if choice == 'y'
|
80
|
+
puts 'Building Compose...'
|
81
|
+
system "sudo #{compose_command} -f docker-compose.prod.yml build"
|
82
|
+
puts 'Building Compose... Done!'
|
83
|
+
else
|
84
|
+
puts 'Build cancelled'
|
85
|
+
end
|
86
|
+
puts '-----------------------------------------------------------------------------------'
|
87
|
+
end
|
88
|
+
|
89
|
+
task :up do
|
90
|
+
puts 'Running Compose... WARNING: you are running this in production'
|
91
|
+
# ask in terminal if you want to continue
|
92
|
+
choice = ask('Are you sure you want to continue? (y/n)')
|
93
|
+
if choice == 'y'
|
94
|
+
puts 'Running Compose...'
|
95
|
+
system "sudo #{compose_command} -f docker-compose.prod.yml up -d --remove-orphans"
|
96
|
+
puts 'Running Compose... Done!'
|
97
|
+
else
|
98
|
+
puts 'Running cancelled'
|
99
|
+
end
|
100
|
+
puts '-----------------------------------------------------------------------------------'
|
101
|
+
end
|
102
|
+
|
103
|
+
task :down do
|
104
|
+
puts 'Stopping Compose... WARNING: you are running this in production'
|
105
|
+
# ask in terminal if you want to continue
|
106
|
+
choice = ask('Are you sure you want to continue? (y/n)')
|
107
|
+
if choice == 'y'
|
108
|
+
puts 'Stopping Compose...'
|
109
|
+
system "sudo #{compose_command} -f docker-compose.prod.yml down"
|
110
|
+
puts 'Stopping Compose... Done!'
|
111
|
+
else
|
112
|
+
puts 'Stopping cancelled'
|
113
|
+
end
|
114
|
+
puts '-----------------------------------------------------------------------------------'
|
115
|
+
end
|
116
|
+
|
117
|
+
task :restart do
|
118
|
+
puts 'Restarting Compose... WARNING: you are running this in production'
|
119
|
+
# ask in terminal if you want to continue
|
120
|
+
choice = ask('Are you sure you want to continue? (y/n)')
|
121
|
+
if choice == 'y'
|
122
|
+
puts 'Restarting Compose...'
|
123
|
+
system "sudo #{compose_command} -f docker-compose.prod.yml restart"
|
124
|
+
puts 'Restarting Compose... Done!'
|
125
|
+
else
|
126
|
+
puts 'Restarting cancelled'
|
127
|
+
end
|
128
|
+
puts '-----------------------------------------------------------------------------------'
|
129
|
+
end
|
130
|
+
|
131
|
+
task :clean_all do
|
132
|
+
puts 'Cleaning Compose... WARNING: you are running this in production'
|
133
|
+
# ask in terminal if you want to continue
|
134
|
+
choice = ask('Are you sure you want to continue? (y/n)')
|
135
|
+
if choice == 'y'
|
136
|
+
puts 'Cleaning Compose...'
|
137
|
+
system "sudo #{compose_command} -f docker-compose.prod.yml down --volumes --remove-orphans"
|
138
|
+
puts 'Cleaning Compose... Done!'
|
139
|
+
else
|
140
|
+
puts 'Cleaning cancelled'
|
141
|
+
end
|
142
|
+
puts '-----------------------------------------------------------------------------------'
|
143
|
+
end
|
144
|
+
|
145
|
+
task :clean_containers do
|
146
|
+
puts "Cleaning Containers... WARNING: you are running this in production"
|
147
|
+
# ask in terminal if you want to continue
|
148
|
+
choice = ask('Are you sure you want to continue? (y/n)')
|
149
|
+
if choice == 'y'
|
150
|
+
puts 'Stopping Containers'
|
151
|
+
system "sudo #{compose_command} -f docker-compose.prod.yml down"
|
152
|
+
puts 'Stopping Containers... Done!'
|
153
|
+
puts 'Cleaning Containers...'
|
154
|
+
system "sudo #{compose_command} -f docker-compose.prod.yml rm -f"
|
155
|
+
puts 'Cleaning Containers... Done!'
|
156
|
+
else
|
157
|
+
puts 'Cleaning cancelled'
|
158
|
+
end
|
159
|
+
puts '-----------------------------------------------------------------------------------'
|
160
|
+
end
|
161
|
+
|
162
|
+
task :clean_images do
|
163
|
+
puts "Cleaning Images... WARNING: you are running this in production"
|
164
|
+
# ask in terminal if you want to continue
|
165
|
+
choice = ask('Are you sure you want to continue? (y/n)')
|
166
|
+
if choice == 'y'
|
167
|
+
puts 'Cleaning Images...'
|
168
|
+
system "sudo #{compose_command} -f docker-compose.prod.yml rmi -f"
|
169
|
+
puts 'Cleaning Images... Done!'
|
170
|
+
else
|
171
|
+
puts 'Cleaning cancelled'
|
172
|
+
end
|
173
|
+
puts '-----------------------------------------------------------------------------------'
|
174
|
+
end
|
175
|
+
|
176
|
+
task :clean_volumes do
|
177
|
+
puts "Cleaning Volumes... WARNING: you are running this in production"
|
178
|
+
# ask in terminal if you want to continue
|
179
|
+
choice = ask('Are you sure you want to continue? (y/n)')
|
180
|
+
if choice == 'y'
|
181
|
+
puts 'Cleaning Volumes...'
|
182
|
+
system "sudo #{compose_command} -f docker-compose.prod.yml down --volumes"
|
183
|
+
puts 'Cleaning Volumes... Done!'
|
184
|
+
else
|
185
|
+
puts 'Cleaning cancelled'
|
186
|
+
end
|
187
|
+
puts '-----------------------------------------------------------------------------------'
|
188
|
+
end
|
189
|
+
|
190
|
+
task :clean_orphans do
|
191
|
+
puts "Cleaning Orphans... WARNING: you are running this in production"
|
192
|
+
# ask in terminal if you want to continue
|
193
|
+
choice = ask('Are you sure you want to continue? (y/n)')
|
194
|
+
if choice == 'y'
|
195
|
+
puts 'Cleaning Orphans...'
|
196
|
+
system "sudo #{compose_command} -f docker-compose.prod.yml down --remove-orphans"
|
197
|
+
puts 'Cleaning Orphans... Done!'
|
198
|
+
else
|
199
|
+
puts 'Cleaning cancelled'
|
200
|
+
end
|
201
|
+
puts '-----------------------------------------------------------------------------------'
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def compose_checker
|
206
|
+
!File.exist?(compose_file)
|
207
|
+
end
|
208
|
+
|
209
|
+
def dockerfile_checker
|
210
|
+
!File.exist?('Dockerfile')
|
211
|
+
end
|
212
|
+
|
213
|
+
tasks_names.each do |task|
|
214
|
+
before_action = "#{namesp}:#{task}"
|
215
|
+
before before_action do
|
216
|
+
dockerfile_checker ? abort("Dockerfile not found.\nYou must have a Dockerfile file.") : nil
|
217
|
+
compose_checker ? (abort "Compose file not found.\nFor development, you must have a #{compose_file} file.") : nil
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rake"
|
4
|
+
require_relative "task_helpers/compose_taskhelper"
|
5
|
+
|
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_test do
|
16
|
+
task :all do
|
17
|
+
puts "Running Test..."
|
18
|
+
system "sudo #{compose_command} run --rm web bundle exec rspec"
|
19
|
+
puts "Running Test... Done!"
|
20
|
+
end
|
21
|
+
|
22
|
+
task :clean_test do
|
23
|
+
puts "Running Clean Test..."
|
24
|
+
system "rake compose:clean_all"
|
25
|
+
puts "Cleaning Compose Images... Done!"
|
26
|
+
puts "Running Tests ..."
|
27
|
+
system "sudo #{compose_command} run --rm web bundle exec rspec"
|
28
|
+
puts "Running Clean Test... Done!"
|
29
|
+
end
|
30
|
+
|
31
|
+
task :controllers do
|
32
|
+
puts "Running Controllers Test..."
|
33
|
+
system "sudo #{compose_command} run --rm web bundle exec rspec spec/controllers"
|
34
|
+
puts "Running Controllers Test... Done!"
|
35
|
+
end
|
36
|
+
|
37
|
+
task :models do
|
38
|
+
puts "Running Models Test..."
|
39
|
+
system "sudo #{compose_command} run --rm web bundle exec rspec spec/models"
|
40
|
+
puts "Running Models Test... Done!"
|
41
|
+
end
|
42
|
+
|
43
|
+
task :requests do
|
44
|
+
puts "Running Requests Test..."
|
45
|
+
system "sudo #{compose_command} run --rm web bundle exec rspec spec/requests"
|
46
|
+
puts "Running Requests Test... Done!"
|
47
|
+
end
|
48
|
+
|
49
|
+
task :helpers do
|
50
|
+
puts "Running Helpers Test..."
|
51
|
+
system "sudo #{compose_command} run --rm web bundle exec rspec spec/helpers"
|
52
|
+
puts "Running Helpers Test... Done!"
|
53
|
+
end
|
54
|
+
|
55
|
+
task :mailers do
|
56
|
+
puts "Running Mailers Test..."
|
57
|
+
system "sudo #{compose_command} run --rm web bundle exec rspec spec/mailers"
|
58
|
+
puts "Running Mailers Test... Done!"
|
59
|
+
end
|
60
|
+
|
61
|
+
task :routing do
|
62
|
+
puts "Running Routing Test..."
|
63
|
+
system "sudo #{compose_command} run --rm web bundle exec rspec spec/routing"
|
64
|
+
puts "Running Routing Test... Done!"
|
65
|
+
end
|
66
|
+
|
67
|
+
task :views do
|
68
|
+
puts "Running Views Test..."
|
69
|
+
system "sudo #{compose_command} run --rm web bundle exec rspec spec/views"
|
70
|
+
puts "Running Views Test... Done!"
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "taskhelper"
|
4
|
+
|
5
|
+
|
6
|
+
class TaskHelpers::ComposeTaskhelper < TaskHelpers::Taskhelper
|
7
|
+
def compose_command
|
8
|
+
@compose_comand ||= compose_command_finder
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def compose_command_finder
|
13
|
+
@command = ["docker compose", "docker-compose"]
|
14
|
+
@command.each do |command|
|
15
|
+
system "#{command} --version > /dev/null 2>&1"
|
16
|
+
return command if $?.success?
|
17
|
+
command = false unless $?.success?
|
18
|
+
end
|
19
|
+
raise ComposeError unless command == false
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TaskHelpers
|
4
|
+
class Taskhelper
|
5
|
+
class ComposeError < StandardError
|
6
|
+
def initialize(message = "Docker Compose is not installed")
|
7
|
+
super
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
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
|
+
|
19
|
+
def env_acceptable?
|
20
|
+
Rails.env.development? || Rails.env.test?
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lucy_dockerunner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- JesusGautamah
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-02-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake-hooks
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
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"
|
30
|
+
email:
|
31
|
+
- lima.jesuscc@gmail.com
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- ".rspec"
|
37
|
+
- ".rubocop.yml"
|
38
|
+
- CHANGELOG.md
|
39
|
+
- CODE_OF_CONDUCT.md
|
40
|
+
- Gemfile
|
41
|
+
- Gemfile.lock
|
42
|
+
- LICENSE.txt
|
43
|
+
- README.md
|
44
|
+
- Rakefile
|
45
|
+
- lib/lucy_dockerunner.rb
|
46
|
+
- lib/lucy_dockerunner/version.rb
|
47
|
+
- lib/tasks/.keep
|
48
|
+
- lib/tasks/compose.rake
|
49
|
+
- lib/tasks/compose_db.rake
|
50
|
+
- lib/tasks/compose_logs.rake
|
51
|
+
- lib/tasks/compose_prod.rake
|
52
|
+
- lib/tasks/compose_test.rake
|
53
|
+
- lib/tasks/task_helpers/compose_taskhelper.rb
|
54
|
+
- lib/tasks/task_helpers/taskhelper.rb
|
55
|
+
- sig/lucy_dockerunner.rbs
|
56
|
+
homepage: https://github.com/JesusGautamah/lucy_dockerunner
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata:
|
60
|
+
allowed_push_host: https://rubygems.org
|
61
|
+
homepage_uri: https://github.com/JesusGautamah/lucy_dockerunner
|
62
|
+
source_code_uri: https://github.com/JesusGautamah/lucy_dockerunner
|
63
|
+
changelog_uri: https://github.com/JesusGautamah/lucy_dockerunner/blob/master/CHANGELOG.md
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 2.6.0
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubygems_version: 3.4.1
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: This gem is a tool to run docker containers with rake commands, good for
|
83
|
+
CI/CD and Rails projects
|
84
|
+
test_files: []
|