Remove service directory on kamal remove
This commit is contained in:
@@ -231,6 +231,7 @@ class Kamal::Cli::App < Kamal::Cli::Base
|
|||||||
stop
|
stop
|
||||||
remove_containers
|
remove_containers
|
||||||
remove_images
|
remove_images
|
||||||
|
remove_service_directory
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -272,6 +273,20 @@ class Kamal::Cli::App < Kamal::Cli::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "remove_service_directory", "Remove the service directory from servers", hide: true
|
||||||
|
def remove_service_directory
|
||||||
|
with_lock do
|
||||||
|
on(KAMAL.hosts) do |host|
|
||||||
|
roles = KAMAL.roles_on(host)
|
||||||
|
|
||||||
|
roles.each do |role|
|
||||||
|
execute *KAMAL.auditor.record("Removed #{KAMAL.config.service_directory} on all servers", role: role), verbosity: :debug
|
||||||
|
execute *KAMAL.server.remove_service_directory
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
desc "version", "Show app version currently running on servers"
|
desc "version", "Show app version currently running on servers"
|
||||||
def version
|
def version
|
||||||
on(KAMAL.hosts) do |host|
|
on(KAMAL.hosts) do |host|
|
||||||
|
|||||||
@@ -181,8 +181,8 @@ class Kamal::Cli::Main < Kamal::Cli::Base
|
|||||||
def remove
|
def remove
|
||||||
confirming "This will remove all containers and images. Are you sure?" do
|
confirming "This will remove all containers and images. Are you sure?" do
|
||||||
with_lock do
|
with_lock do
|
||||||
invoke "kamal:cli:proxy:remove", [], options.without(:confirmed)
|
|
||||||
invoke "kamal:cli:app:remove", [], options.without(:confirmed)
|
invoke "kamal:cli:app:remove", [], options.without(:confirmed)
|
||||||
|
invoke "kamal:cli:proxy:remove", [], options.without(:confirmed)
|
||||||
invoke "kamal:cli:accessory:remove", [ "all" ], options
|
invoke "kamal:cli:accessory:remove", [ "all" ], options
|
||||||
invoke "kamal:cli:registry:logout", [], options.without(:confirmed).merge(skip_local: true)
|
invoke "kamal:cli:registry:logout", [], options.without(:confirmed).merge(skip_local: true)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
class Kamal::Commands::Server < Kamal::Commands::Base
|
class Kamal::Commands::Server < Kamal::Commands::Base
|
||||||
def ensure_service_directory
|
def ensure_service_directory
|
||||||
[ :mkdir, "-p", config.service_directory ]
|
make_directory config.service_directory
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_service_directory
|
||||||
|
remove_directory config.service_directory
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -417,6 +417,7 @@ class CliMainTest < CliTestCase
|
|||||||
assert_match /docker ps --quiet --filter label=service=app | xargs docker stop/, output
|
assert_match /docker ps --quiet --filter label=service=app | xargs docker stop/, output
|
||||||
assert_match /docker container prune --force --filter label=service=app/, output
|
assert_match /docker container prune --force --filter label=service=app/, output
|
||||||
assert_match /docker image prune --all --force --filter label=service=app/, output
|
assert_match /docker image prune --all --force --filter label=service=app/, output
|
||||||
|
assert_match "/usr/bin/env rm -r .kamal/apps/app", output
|
||||||
|
|
||||||
assert_match /docker container stop app-mysql/, output
|
assert_match /docker container stop app-mysql/, output
|
||||||
assert_match /docker container prune --force --filter label=service=app-mysql/, output
|
assert_match /docker container prune --force --filter label=service=app-mysql/, output
|
||||||
|
|||||||
Reference in New Issue
Block a user