First
This commit is contained in:
31
lib/tasks/mrsk/app.rake
Normal file
31
lib/tasks/mrsk/app.rake
Normal file
@@ -0,0 +1,31 @@
|
||||
require_relative "setup"
|
||||
|
||||
app = Mrsk::Commands::App.new(MRSK_CONFIG)
|
||||
|
||||
namespace :mrsk do
|
||||
namespace :app do
|
||||
desc "Build and push app image to servers"
|
||||
task :push do
|
||||
run_locally { execute app.push }
|
||||
on(MRSK_CONFIG.servers) { execute app.pull }
|
||||
end
|
||||
|
||||
desc "Start app on servers"
|
||||
task :start do
|
||||
on(MRSK_CONFIG.servers) { execute app.start }
|
||||
end
|
||||
|
||||
desc "Stop app on servers"
|
||||
task :stop do
|
||||
on(MRSK_CONFIG.servers) { execute app.stop, raise_on_non_zero_exit: false }
|
||||
end
|
||||
|
||||
desc "Restart app on servers"
|
||||
task restart: %i[ stop start ]
|
||||
|
||||
desc "Display information about app containers"
|
||||
task :info do
|
||||
on(MRSK_CONFIG.servers) { |host| puts "Host: #{host}\n" + capture(app.info) + "\n\n" }
|
||||
end
|
||||
end
|
||||
end
|
||||
12
lib/tasks/mrsk/mrsk.rake
Normal file
12
lib/tasks/mrsk/mrsk.rake
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace :mrsk do
|
||||
desc "Push the latest version of the app, ensure Traefik is running, then restart app"
|
||||
task deploy: [ "app:push", "traefik:start", "app:restart" ]
|
||||
|
||||
desc "Display information about Traefik and app containers"
|
||||
task info: [ "traefik:info", "app:info" ]
|
||||
|
||||
desc "Create config stub"
|
||||
task :init do
|
||||
Rails.root.join("config/deploy.yml")
|
||||
end
|
||||
end
|
||||
17
lib/tasks/mrsk/registry.rake
Normal file
17
lib/tasks/mrsk/registry.rake
Normal file
@@ -0,0 +1,17 @@
|
||||
require_relative "setup"
|
||||
|
||||
registry = Mrsk::Commands::Registry.new
|
||||
|
||||
namespace :mrsk do
|
||||
namespace :registry do
|
||||
desc "Login to the registry using ENV['DOCKER_USER'] and ENV['DOCKER_PASSWORD']"
|
||||
task :login do
|
||||
if ENV["DOCKER_USER"].present? && ENV["DOCKER_PASSWORD"].present?
|
||||
run_locally { execute registry.login }
|
||||
on(MRSK_CONFIG.servers) { execute registry.login }
|
||||
else
|
||||
puts "Skipping login due to missing ENV['DOCKER_USER'] and ENV['DOCKER_PASSWORD']"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
10
lib/tasks/mrsk/setup.rb
Normal file
10
lib/tasks/mrsk/setup.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require "sshkit"
|
||||
require "sshkit/dsl"
|
||||
|
||||
include SSHKit::DSL
|
||||
|
||||
MRSK_CONFIG = Mrsk::Configuration.load_file(Rails.root.join("config/deploy.yml"))
|
||||
|
||||
SSHKit::Backend::Netssh.configure do |ssh|
|
||||
ssh.ssh_options = { user: MRSK_CONFIG.ssh_user, auth_methods: [ "publickey" ] }
|
||||
end
|
||||
25
lib/tasks/mrsk/traefik.rake
Normal file
25
lib/tasks/mrsk/traefik.rake
Normal file
@@ -0,0 +1,25 @@
|
||||
require_relative "setup"
|
||||
|
||||
traefik = Mrsk::Commands::Traefik.new
|
||||
|
||||
namespace :mrsk do
|
||||
namespace :traefik do
|
||||
desc "Start Traefik"
|
||||
task :start do
|
||||
on(MRSK_CONFIG.servers) { execute traefik.start, raise_on_non_zero_exit: false }
|
||||
end
|
||||
|
||||
desc "Stop Traefik"
|
||||
task :stop do
|
||||
on(MRSK_CONFIG.servers) { execute traefik.stop, raise_on_non_zero_exit: false }
|
||||
end
|
||||
|
||||
desc "Restart Traefik"
|
||||
task restart: %i[ stop start ]
|
||||
|
||||
desc "Display information about Traefik containers"
|
||||
task :info do
|
||||
on(MRSK_CONFIG.servers) { |host| puts "Host: #{host}\n" + capture(traefik.info) + "\n\n" }
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user