Is a global option better?
This commit is contained in:
@@ -12,6 +12,7 @@ module Mrsk::Cli
|
||||
class_option :quiet, type: :boolean, aliases: "-q", desc: "Minimal logging"
|
||||
|
||||
class_option :version, desc: "Run commands against a specific app version"
|
||||
class_option :use_prebuilt_image, type: :boolean, default: false, desc: "Use prebuilt image, skip building"
|
||||
|
||||
class_option :primary, type: :boolean, aliases: "-p", desc: "Run commands only on primary host instead of all"
|
||||
class_option :hosts, aliases: "-h", desc: "Run commands on these hosts instead of all (separate by comma)"
|
||||
@@ -39,9 +40,10 @@ module Mrsk::Cli
|
||||
|
||||
def initialize_commander(options)
|
||||
MRSK.tap do |commander|
|
||||
commander.config_file = Pathname.new(File.expand_path(options[:config_file]))
|
||||
commander.destination = options[:destination]
|
||||
commander.version = options[:version]
|
||||
commander.config_file = Pathname.new(File.expand_path(options[:config_file]))
|
||||
commander.destination = options[:destination]
|
||||
commander.version = options[:version]
|
||||
commander.use_prebuilt_image = options[:use_prebuilt_image]
|
||||
|
||||
commander.specific_hosts = options[:hosts]&.split(",")
|
||||
commander.specific_roles = options[:roles]&.split(",")
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
class Mrsk::Cli::Build < Mrsk::Cli::Base
|
||||
desc "deliver", "Build app and push app image to registry then pull image on servers"
|
||||
option :use_prebuilt_image, aliases: "-P", type: :boolean, default: false, desc: "Use prebuilt image, skip build"
|
||||
def deliver
|
||||
push unless options[:use_prebuilt_image]
|
||||
push unless MRSK.use_prebuilt_image
|
||||
pull
|
||||
end
|
||||
|
||||
|
||||
@@ -9,44 +9,37 @@ class Mrsk::Cli::Main < Mrsk::Cli::Base
|
||||
end
|
||||
|
||||
desc "deploy", "Deploy app to servers"
|
||||
option :use_prebuilt_image, aliases: "-P", type: :boolean, default: false, desc: "Use prebuilt image, skip build"
|
||||
def deploy
|
||||
runtime = print_runtime do
|
||||
say "Ensure curl and Docker are installed...", :magenta
|
||||
invoke "mrsk:cli:server:bootstrap", [], options.without(:use_prebuilt_image)
|
||||
invoke "mrsk:cli:server:bootstrap"
|
||||
|
||||
say "Log into image registry...", :magenta
|
||||
invoke "mrsk:cli:registry:login", [], options.without(:use_prebuilt_image)
|
||||
invoke "mrsk:cli:registry:login"
|
||||
|
||||
say "Build and push app image...", :magenta
|
||||
invoke "mrsk:cli:build:deliver"
|
||||
|
||||
say "Ensure Traefik is running...", :magenta
|
||||
invoke "mrsk:cli:traefik:boot", [], options.without(:use_prebuilt_image)
|
||||
invoke "mrsk:cli:traefik:boot"
|
||||
|
||||
say "Ensure app can pass healthcheck...", :magenta
|
||||
invoke "mrsk:cli:healthcheck:perform", [], options.without(:use_prebuilt_image)
|
||||
invoke "mrsk:cli:healthcheck:perform"
|
||||
|
||||
invoke "mrsk:cli:app:boot", [], options.without(:use_prebuilt_image)
|
||||
invoke "mrsk:cli:app:boot"
|
||||
|
||||
say "Prune old containers and images...", :magenta
|
||||
invoke "mrsk:cli:prune:all", [], options.without(:use_prebuilt_image)
|
||||
invoke "mrsk:cli:prune:all"
|
||||
end
|
||||
|
||||
audit_broadcast "Deployed app in #{runtime.to_i} seconds" unless options[:skip_broadcast]
|
||||
end
|
||||
|
||||
desc "redeploy", "Deploy app to servers without bootstrapping servers, starting Traefik, pruning, and registry login"
|
||||
option :use_prebuilt_image, aliases: "-P", type: :boolean, default: false, desc: "Use prebuilt image, skip build"
|
||||
def redeploy
|
||||
runtime = print_runtime do
|
||||
unless options[:use_prebuilt_image]
|
||||
say "Build and push app image...", :magenta
|
||||
invoke "mrsk:cli:build:push"
|
||||
end
|
||||
|
||||
say "Pull image onto servers...", :magenta
|
||||
invoke "mrsk:cli:build:pull"
|
||||
say "Build and push app image...", :magenta
|
||||
invoke "mrsk:cli:build:deliver"
|
||||
|
||||
say "Ensure app can pass healthcheck...", :magenta
|
||||
invoke "mrsk:cli:healthcheck:perform"
|
||||
|
||||
Reference in New Issue
Block a user