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.
This commit is contained in:
Jeena 2026-01-22 01:08:18 +09:00
parent 8171760807
commit a56da84b7a

View file

@ -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()