Building doesn't need a deploy lock
This commit is contained in:
@@ -5,87 +5,81 @@ class Kamal::Cli::Build < Kamal::Cli::Base
|
|||||||
|
|
||||||
desc "deliver", "Build app and push app image to registry then pull image on servers"
|
desc "deliver", "Build app and push app image to registry then pull image on servers"
|
||||||
def deliver
|
def deliver
|
||||||
mutating do
|
push
|
||||||
push
|
pull
|
||||||
pull
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "push", "Build and push app image to registry"
|
desc "push", "Build and push app image to registry"
|
||||||
def push
|
def push
|
||||||
mutating do
|
cli = self
|
||||||
cli = self
|
|
||||||
|
|
||||||
verify_local_dependencies
|
verify_local_dependencies
|
||||||
run_hook "pre-build"
|
run_hook "pre-build"
|
||||||
|
|
||||||
uncommitted_changes = Kamal::Git.uncommitted_changes
|
uncommitted_changes = Kamal::Git.uncommitted_changes
|
||||||
|
|
||||||
if KAMAL.config.builder.git_clone?
|
if KAMAL.config.builder.git_clone?
|
||||||
if uncommitted_changes.present?
|
if uncommitted_changes.present?
|
||||||
say "Building from a local git clone, so ignoring these uncommitted changes:\n #{uncommitted_changes}", :yellow
|
say "Building from a local git clone, so ignoring these uncommitted changes:\n #{uncommitted_changes}", :yellow
|
||||||
end
|
|
||||||
|
|
||||||
prepare_clone
|
|
||||||
elsif uncommitted_changes.present?
|
|
||||||
say "Building with uncommitted changes:\n #{uncommitted_changes}", :yellow
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get the command here to ensure the Dir.chdir doesn't interfere with it
|
prepare_clone
|
||||||
push = KAMAL.builder.push
|
elsif uncommitted_changes.present?
|
||||||
|
say "Building with uncommitted changes:\n #{uncommitted_changes}", :yellow
|
||||||
|
end
|
||||||
|
|
||||||
run_locally do
|
# Get the command here to ensure the Dir.chdir doesn't interfere with it
|
||||||
begin
|
push = KAMAL.builder.push
|
||||||
KAMAL.with_verbosity(:debug) do
|
|
||||||
Dir.chdir(KAMAL.config.builder.build_directory) { execute *push }
|
|
||||||
end
|
|
||||||
rescue SSHKit::Command::Failed => e
|
|
||||||
if e.message =~ /(no builder)|(no such file or directory)/
|
|
||||||
warn "Missing compatible builder, so creating a new one first"
|
|
||||||
|
|
||||||
if cli.create
|
run_locally do
|
||||||
KAMAL.with_verbosity(:debug) do
|
begin
|
||||||
Dir.chdir(KAMAL.config.builder.build_directory) { execute *push }
|
KAMAL.with_verbosity(:debug) do
|
||||||
end
|
Dir.chdir(KAMAL.config.builder.build_directory) { execute *push }
|
||||||
end
|
|
||||||
else
|
|
||||||
raise
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
rescue SSHKit::Command::Failed => e
|
||||||
|
if e.message =~ /(no builder)|(no such file or directory)/
|
||||||
|
warn "Missing compatible builder, so creating a new one first"
|
||||||
|
|
||||||
|
if cli.create
|
||||||
|
KAMAL.with_verbosity(:debug) do
|
||||||
|
Dir.chdir(KAMAL.config.builder.build_directory) { execute *push }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
raise
|
||||||
|
end
|
||||||
|
else
|
||||||
|
raise
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "pull", "Pull app image from registry onto servers"
|
desc "pull", "Pull app image from registry onto servers"
|
||||||
def pull
|
def pull
|
||||||
mutating do
|
on(KAMAL.hosts) do
|
||||||
on(KAMAL.hosts) do
|
execute *KAMAL.auditor.record("Pulled image with version #{KAMAL.config.version}"), verbosity: :debug
|
||||||
execute *KAMAL.auditor.record("Pulled image with version #{KAMAL.config.version}"), verbosity: :debug
|
execute *KAMAL.builder.clean, raise_on_non_zero_exit: false
|
||||||
execute *KAMAL.builder.clean, raise_on_non_zero_exit: false
|
execute *KAMAL.builder.pull
|
||||||
execute *KAMAL.builder.pull
|
execute *KAMAL.builder.validate_image
|
||||||
execute *KAMAL.builder.validate_image
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "create", "Create a build setup"
|
desc "create", "Create a build setup"
|
||||||
def create
|
def create
|
||||||
mutating do
|
if (remote_host = KAMAL.config.builder.remote_host)
|
||||||
if (remote_host = KAMAL.config.builder.remote_host)
|
connect_to_remote_host(remote_host)
|
||||||
connect_to_remote_host(remote_host)
|
end
|
||||||
end
|
|
||||||
|
|
||||||
run_locally do
|
run_locally do
|
||||||
begin
|
begin
|
||||||
debug "Using builder: #{KAMAL.builder.name}"
|
debug "Using builder: #{KAMAL.builder.name}"
|
||||||
execute *KAMAL.builder.create
|
execute *KAMAL.builder.create
|
||||||
rescue SSHKit::Command::Failed => e
|
rescue SSHKit::Command::Failed => e
|
||||||
if e.message =~ /stderr=(.*)/
|
if e.message =~ /stderr=(.*)/
|
||||||
error "Couldn't create remote builder: #{$1}"
|
error "Couldn't create remote builder: #{$1}"
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
raise
|
raise
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -93,11 +87,9 @@ class Kamal::Cli::Build < Kamal::Cli::Base
|
|||||||
|
|
||||||
desc "remove", "Remove build setup"
|
desc "remove", "Remove build setup"
|
||||||
def remove
|
def remove
|
||||||
mutating do
|
run_locally do
|
||||||
run_locally do
|
debug "Using builder: #{KAMAL.builder.name}"
|
||||||
debug "Using builder: #{KAMAL.builder.name}"
|
execute *KAMAL.builder.remove
|
||||||
execute *KAMAL.builder.remove
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user