mirror of https://github.com/aliasrobotics/cai.git
cker virtualization for ctf_inside false
This commit is contained in:
parent
3a203cee5f
commit
521c33a6b1
|
|
@ -1 +1 @@
|
|||
{"state":{"hard_state":{"term":0,"vote":0,"commit":0},"conf_state":{"voters":[6120741261401965],"learners":[],"voters_outgoing":[],"learners_next":[],"auto_leave":false}},"latest_snapshot_meta":{"term":0,"index":0},"apply_progress_queue":null,"first_voter":6120741261401965,"peer_address_by_id":{},"peer_metadata_by_id":{},"this_peer_id":6120741261401965}
|
||||
{"state":{"hard_state":{"term":0,"vote":0,"commit":0},"conf_state":{"voters":[6120741261401965],"learners":[],"voters_outgoing":[],"learners_next":[],"auto_leave":false}},"latest_snapshot_meta":{"term":0,"index":0},"apply_progress_queue":null,"first_voter":6120741261401965,"peer_address_by_id":{},"peer_metadata_by_id":{},"this_peer_id":6120741261401965}
|
||||
|
|
|
|||
|
|
@ -2997,3 +2997,40 @@ def setup_ctf():
|
|||
bg="blue"))
|
||||
|
||||
return ctf, messages
|
||||
|
||||
|
||||
def build_docker_container(devcontainer_path: str) -> str:
|
||||
dockerfile_path = os.path.join(devcontainer_path, "Dockerfile")
|
||||
image_name = "cai-container3"
|
||||
container_name = "cai-container3"
|
||||
|
||||
# Try to remove existing container with the same name
|
||||
try:
|
||||
subprocess.run(["docker", "rm", "-f", container_name], check=True)
|
||||
except subprocess.CalledProcessError:
|
||||
pass # If it doesn't exist, continue normally
|
||||
|
||||
# Build the image
|
||||
subprocess.run([
|
||||
"docker", "build",
|
||||
"-t", image_name,
|
||||
"-f", dockerfile_path,
|
||||
devcontainer_path
|
||||
], check=True)
|
||||
|
||||
# Run the container
|
||||
result = subprocess.run([
|
||||
"docker", "run", "-d", "--name", container_name, image_name, "tail", "-f", "/dev/null"
|
||||
], stdout=subprocess.PIPE, check=True, text=True)
|
||||
|
||||
container_id = result.stdout.strip()
|
||||
return container_id
|
||||
|
||||
def remove_container(name_or_id: str):
|
||||
try:
|
||||
# Force removal (stops if running, then removes)
|
||||
subprocess.run(["docker", "rm", "-f", name_or_id], check=True)
|
||||
print(f"Container '{name_or_id}' removed successfully.")
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error removing container {name_or_id}:", e)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue