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:
parent
8171760807
commit
a56da84b7a
1 changed files with 8 additions and 0 deletions
|
|
@ -45,6 +45,14 @@ class OpenCodeContainer:
|
||||||
# Ensure container home directory exists
|
# Ensure container home directory exists
|
||||||
self.container_home_path.mkdir(parents=True, exist_ok=True)
|
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():
|
if not self.image_exists():
|
||||||
self.build_image()
|
self.build_image()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue