bitwalker / distillery

Simplify deployments in Elixir with OTP releases!
MIT License
2.96k stars 396 forks source link

Overriding default application dependencies #534

Open fhunleth opened 5 years ago

fhunleth commented 5 years ago

Is it possible to override the default application dependencies specified in the following link?

https://github.com/bitwalker/distillery/blob/2.0.9/lib/mix/lib/releases/models/release.ex#L15-L30

For better or worse, most Nerves applications don't use config providers so I believe that the mix and distillery dependencies are unused at runtime. This likely also means that artificery is unused for most Nerves users. While none of these dependencies are particularly large, Nerves devices have limited memory and there's interest in minimizing software update sizes.

If making the default application dependency list configurable looks too error-prone, is separating out the config providers to another project an option? I assume that would make distillery and mix compile-time only deps, right?

bitwalker commented 5 years ago

They could be stripped out with a plugin. Distillery is required for the config providers, pidfile support, as well as the entrypoint for the CLI that the scripts use. Nerves doesn't currently use any of those features though, so your point is a valid one.

The way I'm thinking of approaching this is by extracting out the core release functionality into a new package, distillery_core, which will only contain the APIs for building the release. Nerves could then invoke those APIs directly from its own tasks, rather than invoke Distillery tasks. The main distillery package would then add on everything that is currently in Distillery today. I will also extract out the config provider core, and the Elixir provider, since those aren't strictly a releases thing once they make their way to core, so it doesn't need to be part of Distillery's core either.

So to answer your question more directly, for Nerves, I would either use an existing plugin you've written, or add a new one, which modifies the Release struct by stripping out the default applications you don't need. You would need to make sure Nerves apps set runtime: false on the Distillery dependency as well. I would do this at the earliest plugin stage possible, probably before_assembly. Once the changes I've made to extract out Distillery's core are done, you could just switch over to that, and avoid the need to extensively modify the generated release just for Nerves projects (as another side-effect of extracting out the core, I plan to also make some parts more configurable, e.g. boot script generation, shell scripts, etc.).