container: Pull fresh base image on update and drop unused constant

This commit is contained in:
Jeena 2026-05-28 21:56:38 +00:00
parent 7507534cf0
commit 7984b9129a

View file

@ -27,7 +27,6 @@ class AgentContainer:
IMAGE = "agent-container:latest" IMAGE = "agent-container:latest"
CONTAINER_PREFIX = "ac-" CONTAINER_PREFIX = "ac-"
DATA_DIR_NAME = "agent-container" DATA_DIR_NAME = "agent-container"
PROJECT_ID_LEN = 12
START_TIMEOUT = 3.0 START_TIMEOUT = 3.0
def __init__(self): def __init__(self):
@ -215,7 +214,7 @@ class AgentContainer:
== 0 == 0
) )
def build_image(self, no_cache: bool = False) -> None: def build_image(self, no_cache: bool = False, pull: bool = False) -> None:
logger.info( logger.info(
f"Building image '{self.IMAGE}' with user {self.host_username} ({self.host_uid}:{self.host_gid})" f"Building image '{self.IMAGE}' with user {self.host_username} ({self.host_uid}:{self.host_gid})"
) )
@ -233,6 +232,8 @@ class AgentContainer:
] ]
if no_cache: if no_cache:
cmd.append("--no-cache") cmd.append("--no-cache")
if pull:
cmd.append("--pull")
cmd.append(str(self.docker_context_dir)) cmd.append(str(self.docker_context_dir))
self._run_cmd(cmd) self._run_cmd(cmd)
@ -297,7 +298,7 @@ class AgentContainer:
stderr=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
) )
logger.info("Rebuilding image with latest versions...") logger.info("Rebuilding image with latest versions...")
self.build_image(no_cache=True) self.build_image(no_cache=True, pull=True)
logger.info("Update complete. Containers will be recreated on next run.") logger.info("Update complete. Containers will be recreated on next run.")
def purge(self) -> None: def purge(self) -> None: