devbox
devbox copied to clipboard
[Feature]: exit_hook like in devbox.json
Is your feature request related to a problem you're trying to solve? Please describe. I often encounter a challenge when working with environment variables, particularly in managing domain configurations during development sessions. For instance, I frequently need to add and remove domain entries manually when starting or ending my development environment. This manual process is time-consuming and prone to errors. For example, I'm always frustrated when I forget to remove a domain entry after a session, leading to potential conflicts or security issues.
Describe the solution you'd like I would like to introduce an exit_hook feature, similar to the existing init_hook, that automatically executes specified scripts or command lines upon exiting the environment. This feature would allow users to define cleanup or reset tasks that need to be performed when they are done with their development session.
For instance, after using init_hook to add domain entries (e.g., sudo hostctl add domains expensify dev.new.expensify.com), the exit_hook would automatically remove these entries (e.g., sudo hostctl remove expensify) when the session ends. This automation would ensure a clean and secure development environment without manual intervention.
Describe alternatives you've considered
- Create a feature like in devbox.json : https://docs.docker.com/compose/compose-file/compose-file-v3/#extra_hosts
- Create a plugin for dnsmasq : where you can configure the dnsmasq.conf to create a containerized DNS host without touching the /etc/hosts of the host system
Additional context This feature would enhance workflow efficiency and security for developers who frequently modify their environment for testing or development purposes. I am not aware of any previous requests for this feature. If this has been discussed or requested before, I would appreciate a link to that discussion for further insights.
Example usage:
init_hook: ["sudo hostctl add domains expensify dev.new.expensify.com"] exit_hook: ["sudo hostctl remove expensify"]
### Tasks