From a56da84b7a3d58cc0587cd567eb10cb3191a3f33 Mon Sep 17 00:00:00 2001 From: Jeena Date: Thu, 22 Jan 2026 01:08:18 +0900 Subject: [PATCH] Prepopulate container-home with project dirs This is to fix the problem with docker creating those directories to mount it inside of the container-home. This only happens when the project path is inside of $HOME which is mounted to the .local/share/opencode-container/cantainer-home With it like this, the empty directories are owned by the local user and not root and it's easier to clean up in the future. --- opencode-container.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/opencode-container.py b/opencode-container.py index d4dcb96..84a7919 100755 --- a/opencode-container.py +++ b/opencode-container.py @@ -45,6 +45,14 @@ class OpenCodeContainer: # Ensure container home directory exists self.container_home_path.mkdir(parents=True, exist_ok=True) + # Pre-create project directory structure to prevent root-owned directories + try: + relative_path = self.project_path.relative_to(Path.home()) + (self.container_home_path / relative_path).mkdir(parents=True, exist_ok=True) + except ValueError: + # Project is outside home directory - no action needed + pass + if not self.image_exists(): self.build_image()