[Suggestion] Hooks that run only during the creation of the container
- Linguagem predominante
- Go
- Estrelas
- 13k
- Forks
- 541
- Merge médio
- 20h 47min
- PRs com merge (30d)
- 4
Descrição
**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**
Guia de contribuição
Direção de pesquisa
Analise os scripts distrobox-create e distrobox-init para entender o ciclo de vida do contêiner. Os create_hooks precisariam ser adicionados ao distrobox-create e armazenados para que não fossem executados novamente. Verifique como additional_packages e init_hooks estão implementados atualmente. Um teste envolve criar um contêiner com um hook que grava um arquivo e, em seguida, entrar no contêiner para verificar se o hook foi executado apenas uma vez.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- bash, docker, shell
- Domínio
- cli, developer-experience, tooling
- Tipo de issue
- Funcionalidade
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Ativa
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 55/100