Skip to content
Closed
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
1 change: 1 addition & 0 deletions changes/810.housekeeping
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changed many invoke tasks to remove the container after running the command by default.
7 changes: 4 additions & 3 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ def task_wrapper(function=None):
return task_wrapper


def run_command(context, exec_cmd, port=None):
def run_command(context, exec_cmd, port=None, rm=True):
"""Wrapper to run the invoke task commands.

Args:
context ([invoke.task]): Invoke task object.
exec_cmd ([str]): Command to run.
port (int): Used to serve local docs.
rm (bool): Whether to remove the container after running the command.

Returns:
result (obj): Contains Invoke result from running task.
Expand All @@ -86,12 +87,12 @@ def run_command(context, exec_cmd, port=None):
)
if port:
result = context.run(
f"docker run -it -p {port} -v {context.netutils.pwd}:/local {context.netutils.image_name}:{context.netutils.image_ver} sh -c '{exec_cmd}'",
f"docker run -it {'--rm' if rm else ''} -p {port} -v {context.netutils.pwd}:/local {context.netutils.image_name}:{context.netutils.image_ver} sh -c '{exec_cmd}'",
pty=True,
)
else:
result = context.run(
f"docker run -it -v {context.netutils.pwd}:/local {context.netutils.image_name}:{context.netutils.image_ver} sh -c '{exec_cmd}'",
f"docker run -it {'--rm' if rm else ''} -v {context.netutils.pwd}:/local {context.netutils.image_name}:{context.netutils.image_ver} sh -c '{exec_cmd}'",
pty=True,
)

Expand Down
Loading