Allow running detached app commands

this is useful for long running rake tasks or scripts
that can be run without having to keep open connection to the server.

Example:
```
kamal app exec 'bin/rails db:backfill_task' --detach
```
This commit is contained in:
Ali Ismayilov
2024-08-07 15:32:01 +02:00
parent b9804a07aa
commit dbe0c3a7f8
4 changed files with 17 additions and 2 deletions

View File

@@ -7,9 +7,10 @@ module Kamal::Commands::App::Execution
*command
end
def execute_in_new_container(*command, interactive: false, env:)
def execute_in_new_container(*command, interactive: false, detach: false, env:)
docker :run,
("-it" if interactive),
("--detach" if detach),
"--rm",
"--network", "kamal",
*role&.env_args(host),