89luca89 / 89luca89/distrobox

[Suggestion] Hooks that run only during the creation of the container

未關閉
#1,673 15 則留言 19 個 reaction 已指派 0 人 在 GitHub 檢視
enhancement
主要語言
Go
星號
13k
分支
541
平均合併
20 小時 47 分鐘
30 天內合併 PR
4

描述

**Is your feature request related to a problem? Please describe.**
Currently, there are three ways to modify a container image with distrobox: the `additional_packages` list, the `init_hooks` script, and the `pre_init_hooks` script. Each method fires when distrobox-init runs, which is to say, every single time a container is started, including when entering it after a period of inactivity with distrobox-enter. These hooks can potentially burn a lot of time and would seem to go against distrobox's philosophy of making distrobox-enter as performant as possible. The official distrobox-assemble documentation includes [examples](https://github.com/89luca89/distrobox/blob/main/docs/usage/distrobox-assemble.md#examples) that install Go, Deno, and Bun using the init hook, and these operations, again, fire during every container start.

**Describe the solution you'd like**
Perhaps there should be a `create_hooks` script that would run only when creating a container with distrobox-create. And distrobox should consider moving the "Installing basic packages" step out of distrobox-init and into this hook. Once a container has been created, I can't think of a good reason why the package list should be installed again. If any are missing, it would be because the user explicitly uninstalled them.

**Describe alternatives you've considered**
You could build custom images for distrobox using a Dockerfile, but that's a lot of ceremony for the kinds of customizations we apply to our distrobox containers. Hence why we have the additional packages list and the hooks in the first place.

You could clone an existing container to drop the defined hooks, while retaining your customizations, but that's not a very intuitive solution. It's only documented in a GitHub [discussion](https://github.com/89luca89/distrobox/issues/1091).

**Additional context**

貢獻指南

開啟貢獻指南

研究方向

查看 distrobox-create 和 distrobox-init 腳本,以了解容器的生命週期。需要將 create_hooks 新增至 distrobox-create 並儲存,以便不會再次執行它們。檢查 additional_packages 和 init_hooks 目前是如何實作的。測試包括建立一個帶有會寫入檔案的 hook 的容器,然後進入容器以驗證該 hook 只執行了一次。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
bash, docker, shell
領域
cli, developer-experience, tooling
Issue 類型
功能
難度
3/5
預估耗時
1-2 天
活躍度
活躍
描述清晰度
描述清楚
新手友好度
55/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。