Merge pull request #1544 from prullmann/kamal-exec-piping

Allow piping into kamal exec #1485
This commit is contained in:
Donal McBreen
2025-06-16 07:52:03 +01:00
committed by GitHub
7 changed files with 75 additions and 20 deletions

View File

@@ -56,14 +56,14 @@ class Kamal::Commands::Accessory < Kamal::Commands::Base
def execute_in_existing_container(*command, interactive: false)
docker :exec,
("-it" if interactive),
(docker_interactive_args if interactive),
service_name,
*command
end
def execute_in_new_container(*command, interactive: false)
docker :run,
("-it" if interactive),
(docker_interactive_args if interactive),
"--rm",
*network_args,
*env_args,

View File

@@ -1,7 +1,7 @@
module Kamal::Commands::App::Execution
def execute_in_existing_container(*command, interactive: false, env:)
docker :exec,
("-it" if interactive),
(docker_interactive_args if interactive),
*argumentize("--env", env),
container_name,
*command
@@ -9,7 +9,7 @@ module Kamal::Commands::App::Execution
def execute_in_new_container(*command, interactive: false, detach: false, env:)
docker :run,
("-it" if interactive),
(docker_interactive_args if interactive),
("--detach" if detach),
("--rm" unless detach),
"--network", "kamal",

View File

@@ -122,5 +122,9 @@ module Kamal::Commands
def ensure_local_buildx_installed
docker :buildx, "version"
end
def docker_interactive_args
STDIN.isatty ? "-it" : "-i"
end
end
end