lucy_dockerunner 0.1.7 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7902c6fdd608e972b6025b32f6ef8731e37fa5e8249ef0446f0503ff450e184
4
- data.tar.gz: ff2d987b86f299f91fe34060adfe93b07a00199f44cd3afdf730ce5347797878
3
+ metadata.gz: c5982619210e56d52470c5a60eb936282f0e37f958c993c0511c25c546b25004
4
+ data.tar.gz: b6a090ac20f0d81b44c2a78c1488ba354ab43d5f261945fb053c43d182d17058
5
5
  SHA512:
6
- metadata.gz: 7f530d7c039fc703c258e6c791a12367255c7ca4cc1d0ee2e5eda38f5ad5686c532889e4b3a11a4b9137c6a00b93ee78a8c4b78d82d03b8ea151421ce00ce947
7
- data.tar.gz: 6b58db241568b140abff172148afef7bae3986357ed6dd7fe56abe4f354fdacc427072718332e2fe9751fc5628d8431ea7e09fbbc5b7a98c1100622ab34b1b94
6
+ metadata.gz: f08537f76a386d8c07cbe474a3297d56851984103a07e8dae69f64585687088b607e2e6ed260e5cf01903462546e5ecec13a4320f0f704bf8f2fd4939b63ae07
7
+ data.tar.gz: 253c9000552f954a2522c8104a69e7474b2c88b80691fd713216dbea5cecdd97043956e0a1c3032f9e43999ed9e9805f1b9fcd8174960f7fc53cc1bc3e1806e3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lucy_dockerunner (0.1.7)
4
+ lucy_dockerunner (0.1.9)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -28,6 +28,16 @@ It's important to have .env files separated by environment, for example:
28
28
  - .env.production
29
29
 
30
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.
31
+
32
+ ## Services
33
+ This gem requires the following services names to be included in the docker-compose.yml and docker-compose.prod.yml files:
34
+ <!-- db - redis - web - sidekiq -->
35
+ * db
36
+ * redis
37
+ * web
38
+ * sidekiq
39
+
40
+ ##### more services will be added in the future, for example: mailcatcher, elasticsearch, webpack, etc.
31
41
  ## Installation
32
42
 
33
43
  You can install the gem by executing:
@@ -127,9 +137,6 @@ LucyDockerunner.load_tasks
127
137
  ````bash
128
138
  $ rake compose:up
129
139
  ````
130
-
131
- ## References
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.
133
140
  ## Contributing
134
141
 
135
142
  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).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LucyDockerunner
4
- VERSION = "0.1.7"
4
+ VERSION = "0.1.9"
5
5
  end
@@ -2,11 +2,9 @@
2
2
 
3
3
  require "rake"
4
4
  require_relative "task_helpers/compose_taskhelper"
5
- require_relative "../rake/lucyd_hooks"
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
9
- clean_stopped]
7
+ @tasks_names = %w[install build up down restart clean_all clean_volumes clean_orphans clean_images]
10
8
  end
11
9
 
12
10
  def namesp
@@ -71,6 +69,30 @@ namespace :compose do
71
69
  system "sudo #{compose_command} down"
72
70
  puts "Stopping Compose... Done!"
73
71
  end
72
+
73
+ task :bot_detach do
74
+ puts "Running Bot Detached..."
75
+ system "sudo #{compose_command} up -d bot"
76
+ puts "Running Bot Detached... Done!"
77
+ end
78
+
79
+ task :telegram_detach do
80
+ puts "Running Telegram Detached..."
81
+ system "sudo #{compose_command} up -d telegram"
82
+ puts "Running Telegram Detached... Done!"
83
+ end
84
+
85
+ task :discord_detach do
86
+ puts "Running Discord Detached..."
87
+ system "sudo #{compose_command} up -d discord"
88
+ puts "Running Discord Detached... Done!"
89
+ end
90
+
91
+ task :nginx_detach do
92
+ puts "Running Nginx Detached..."
93
+ system "sudo #{compose_command} up -d nginx"
94
+ puts "Running Nginx Detached... Done!"
95
+ end
74
96
 
75
97
  task :db_detach do
76
98
  puts "Running Database Detached..."
@@ -84,11 +106,11 @@ namespace :compose do
84
106
  puts "Running Redis Detached... Done!"
85
107
  end
86
108
 
87
- task :back_detach do
88
- puts "Running Backend Detached..."
89
- system "sudo #{compose_command} up -d --remove-orphans db redis sidekiq"
90
- puts "Running Backend Detached... Done!"
91
- end
109
+ # task :back_detach do
110
+ # puts "Running Backend Detached..."
111
+ # system "sudo #{compose_command} up -d --remove-orphans db redis sidekiq"
112
+ # puts "Running Backend Detached... Done!"
113
+ # end
92
114
 
93
115
  task :restart do
94
116
  puts "Restarting Compose..."
@@ -114,21 +136,7 @@ namespace :compose do
114
136
 
115
137
  task :clean_all do
116
138
  puts "Cleaning Compose..."
117
- puts "Stopping Compose..."
118
- system "sudo #{compose_command} down"
119
- puts "Stopping Compose... Done!"
120
- puts "Removing Containers..."
121
- system "sudo #{compose_command} rm -f"
122
- puts "Removing Containers... Done!"
123
- puts "Removing Images..."
124
- system "sudo #{compose_command} rmi -f"
125
- puts "Removing Images... Done!"
126
- puts "Removing Volumes..."
127
- system "sudo #{compose_command} down -v"
128
- puts "Removing Volumes... Done!"
129
- puts "Removing Orphans..."
130
- system "sudo #{compose_command} down --remove-orphans"
131
- puts "Removing Networks... Done!"
139
+ system "sudo docker system prune"
132
140
  puts "Cleaning Compose... Done!"
133
141
  end
134
142
 
@@ -177,20 +185,20 @@ namespace :compose do
177
185
  end
178
186
  end
179
187
 
180
- def compose_checker
181
- !File.exist?(compose_file)
188
+ def compose_exist?
189
+ File.exist?(compose_file)
182
190
  end
183
191
 
184
- def dockerfile_checker
185
- !File.exist?("Dockerfile")
192
+ def dockerfile_exist?
193
+ File.exist?("Dockerfile")
186
194
  end
187
195
 
188
196
  tasks_names.each do |task|
189
197
  before_action = "#{namesp}:#{task}"
190
- bef before_action do
198
+ Rake::Task[before_action].enhance do
191
199
  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.")
200
+ compose_abort_error = "Compose file not found.\nYou must have a docker-compose.yml file."
201
+ abort(docker_abort_error) unless dockerfile_exist?
202
+ abort(compose_abort_error) unless compose_exist?
195
203
  end
196
204
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "rake"
4
4
  require_relative "task_helpers/compose_taskhelper"
5
- require_relative "../rake/lucyd_hooks"
6
5
 
7
6
  def task_helper
8
7
  @task_helper ||= TaskHelpers::ComposeTaskhelper.new
@@ -12,6 +12,30 @@ def compose_command
12
12
  end
13
13
 
14
14
  namespace :compose_logs do
15
+ task :discord do
16
+ puts "Showing Discord Logs..."
17
+ system "sudo #{compose_command} logs discord"
18
+ puts "Showing Discord Logs... Done!"
19
+ end
20
+
21
+ task :telegram do
22
+ puts "Showing Telegram Logs..."
23
+ system "sudo #{compose_command} logs telegram"
24
+ puts "Showing Telegram Logs... Done!"
25
+ end
26
+
27
+ task :bot do
28
+ puts "Showing Bot Logs..."
29
+ system "sudo #{compose_command} logs bot"
30
+ puts "Showing Bot Logs... Done!"
31
+ end
32
+
33
+ task :nginx do
34
+ puts "Showing Nginx Logs..."
35
+ system "sudo #{compose_command} logs nginx"
36
+ puts "Showing Nginx Logs... Done!"
37
+ end
38
+
15
39
  task :web do
16
40
  puts "Showing Web Logs..."
17
41
  system "sudo #{compose_command} logs web"
@@ -42,6 +66,30 @@ namespace :compose_logs do
42
66
  puts "Showing All Logs... Done!"
43
67
  end
44
68
 
69
+ task :tail_discord do
70
+ puts "Tailing Discord Logs..."
71
+ system "sudo #{compose_command} logs -f discord"
72
+ puts "Tailing Discord Logs... Done!"
73
+ end
74
+
75
+ task :tail_telegram do
76
+ puts "Tailing Telegram Logs..."
77
+ system "sudo #{compose_command} logs -f telegram"
78
+ puts "Tailing Telegram Logs... Done!"
79
+ end
80
+
81
+ task :tail_bot do
82
+ puts "Tailing Bot Logs..."
83
+ system "sudo #{compose_command} logs -f bot"
84
+ puts "Tailing Bot Logs... Done!"
85
+ end
86
+
87
+ task :tail_nginx do
88
+ puts "Tailing Nginx Logs..."
89
+ system "sudo #{compose_command} logs -f nginx"
90
+ puts "Tailing Nginx Logs... Done!"
91
+ end
92
+
45
93
  task :tail_web do
46
94
  puts "Tailing Web Logs..."
47
95
  system "sudo #{compose_command} logs -f web"
@@ -4,8 +4,7 @@ require "rake"
4
4
  require_relative "task_helpers/compose_taskhelper"
5
5
 
6
6
  def tasks_names
7
- @tasks_names = %w[install build up down restart clean_all clean_volumes clean_orphans clean_images clean_networks
8
- clean_stopped]
7
+ @tasks_names = %w[install build up down restart clean_all clean_volumes clean_orphans clean_images]
9
8
  end
10
9
 
11
10
  def namesp
@@ -232,20 +231,21 @@ namespace :compose_prod do
232
231
  end
233
232
  end
234
233
 
235
- def compose_checker
236
- !File.exist?(compose_file)
234
+ def compose_exist?
235
+ File.exist?(compose_file)
237
236
  end
238
237
 
239
- def dockerfile_checker
240
- !File.exist?("Dockerfile")
238
+ def dockerfile_exist?
239
+ File.exist?("Dockerfile")
241
240
  end
242
241
 
243
242
  tasks_names.each do |task|
244
243
  before_action = "#{namesp}:#{task}"
245
- bef before_action do
244
+ Rake::Task[before_action].enhance do
246
245
  docker_abort_error = "Dockerfile not found.\nYou must have a Dockerfile file."
247
246
  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
+ abort(docker_abort_error) unless dockerfile_exist?
248
+ abort(compose_abort_error) unless compose_exist?
250
249
  end
251
250
  end
251
+
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.7
4
+ version: 0.1.9
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-16 00:00:00.000000000 Z
11
+ date: 2023-03-26 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.
@@ -31,7 +31,6 @@ files:
31
31
  - Rakefile
32
32
  - lib/lucy_dockerunner.rb
33
33
  - lib/lucy_dockerunner/version.rb
34
- - lib/rake/lucyd_hooks.rb
35
34
  - lib/tasks/.keep
36
35
  - lib/tasks/compose.rake
37
36
  - lib/tasks/compose_assets.rake
@@ -66,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
65
  - !ruby/object:Gem::Version
67
66
  version: '0'
68
67
  requirements: []
69
- rubygems_version: 3.4.1
68
+ rubygems_version: 3.4.6
70
69
  signing_key:
71
70
  specification_version: 4
72
71
  summary: This gem is a tool to run docker containers with rake commands, good for
@@ -1,23 +0,0 @@
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