Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont build image if it has already been pushed #885

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/kamal/cli/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class BuildError < StandardError; end

desc "deliver", "Build app and push app image to registry then pull image on servers"
def deliver
push
push unless pushed?
pull
end

Expand Down Expand Up @@ -157,4 +157,10 @@ def pull_on_hosts(hosts)
execute *KAMAL.builder.validate_image
end
end

def pushed?
run_locally { execute *KAMAL.docker.manifest(KAMAL.builder.absolute_image) }
rescue SSHKit::Command::Failed
false
end
end
3 changes: 2 additions & 1 deletion lib/kamal/commands/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

class Kamal::Commands::Builder < Kamal::Commands::Base
delegate :create, :remove, :push, :clean, :pull, :info, :inspect_builder, :validate_image, :first_mirror, to: :target
delegate :local?, :remote?, to: "config.builder"
delegate :absolute_image, :builder, to: :config
delegate :local?, :remote?, to: :builder

include Clone

Expand Down
4 changes: 4 additions & 0 deletions lib/kamal/commands/docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def running?
docker :version
end

def manifest(tag)
docker :manifest, :inspect, tag
end

# Do we have superuser access to install Docker and start system services?
def superuser?
[ '[ "${EUID:-$(id -u)}" -eq 0 ] || command -v sudo >/dev/null || command -v su >/dev/null' ]
Expand Down
4 changes: 2 additions & 2 deletions test/integration/main_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class MainTest < IntegrationTest
test "deploy, redeploy, rollback, details and audit" do
first_version = latest_app_version
first_version = update_app_rev

assert_app_is_down

Expand Down Expand Up @@ -38,7 +38,7 @@ class MainTest < IntegrationTest
test "app with roles" do
@app = "app_with_roles"

version = latest_app_version
version = update_app_rev

assert_app_is_down

Expand Down