1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-10-01 08:44:09 +02:00

feat(start): Add --detach flag

This will create a dedicated worktree for the instance.

App listed to be enabled will also benefit from their own worktrees.

The worktree is cleanup when the instance is destroyed.
This commit is contained in:
Louis Chmn 2026-08-13 19:32:23 +02:00
commit 0e702f7b87
9 changed files with 339 additions and 27 deletions

View file

@ -81,7 +81,12 @@ impl<'a> Mapping<'a> {
}
}
pub async fn create(&self, id: &str, config: &HazeConfig) -> Result<()> {
pub async fn create(
&self,
id: &str,
config: &HazeConfig,
source_root: &Utf8Path,
) -> Result<()> {
if !self.create {
return Ok(());
}
@ -96,6 +101,19 @@ impl<'a> Mapping<'a> {
MappingType::File => write(source, "").await.into_diagnostic()?,
}
// For worktrees, pre-create mountpoints within /var/www/html to prevent docker from creating them as root.
if self.target.starts_with("/var/www/html") {
let local_target = source_root.join(
self.target
.strip_prefix("/var/www/html")
.unwrap_or(&self.target),
);
match self.mapping_type {
MappingType::Folder => create_dir_all(local_target).await.into_diagnostic()?,
MappingType::File => write(local_target, "").await.into_diagnostic()?,
}
}
Ok(())
}