I think the idea is really tantalizing, does anyone have an idea as to the feasibility? I’m sure it would work on a co-located server but something like AWS probably wouldn’t support it.
I played around with deploying Nerves “firmware” to the cloud a while back. My notes are here: https://github.com/fhunleth/vultr_example. I originally looked at deploying to AWS, and it seemed feasible but I got a little lost in Amazon terminology. Getting something to work on Vultr was easy so I went there instead.
Some takeaways from doing this were:
It’s definitely possible.
Server hardware and networking are simpler than what we have to deal with in the embedded use cases, so there are opportunities to streamline the tooling and base libraries for ease-of-use.
Bootstrapping servers to work with Nerves needs work. For Vultr, I have an iPXE script to load the first image, but it’s really tedious to use. From there on, you can update it via nerves_firmware_ssh which is easier.
I don’t know enough about server deployment and operations to know what should be in the base Nerves image and what all is expected in the tooling. For example, it’s possible to put Postgres in the base image (per the reddit post), but I’m not sure that’s desirable. It seems easier (to me) to have a dedicated server for the database rather than combining it.
Anyway, Nerves in the cloud hasn’t been a focus for me, but if others want to pursue it, I certainly would help on low level details.
A friend told me that it’s possible with enough hackery. The main issue had something to do with getting erlinit to play nicely with Docker. Unfortunately, they did this a while ago and didn’t remember any more details.
If you’re looking into this, erlinit is a minimal init process for Nerves devices. A few minimal init projects exist for Docker like dumb-init and tini, so there may be a hint in one of them. If you or anyone finds out what’s needed, please file an issue on the erlinit Github.
I’ve pretty much abandoned this due to lack of interest. My notes for deploying to a Vultr VPS are still around, but I haven’t kept the Nerves system up with the latest Nerves 1.0-rc updates so there might be some small breakages. Don’t let me dissuade you from exploring this route, though. Many aspects of deploying small self-contained “firmware” bundles to servers appeals to me too, but there’s quite a bit of work left to make this usable in a real environment.
I doubt it. Nerves has a very self-contained and static view of the world: the root filesystem is read-only, adding some OS packages can be non-trivial (no apt-get), and Elixir or Erlang control pretty much everything rather than more standard things like systemd and other Linux tooling. If your server doesn’t have many non-Elixir dependencies and you feel that existing tooling is heavy weight, I can see a Nerves approach appealing to you.
Fwiw, I’d also explore modifying Nerves to output a Docker image. Since the image wouldn’t need a Linux kernel or bootloader, it would even be more minimal - containing only the C runtime libraries, ERTS, your beams, and cross-compiled ports&NIFs. However, it would hook into existing infrastructure built around Docker and that seems useful.
I’m also interested in hearing from anyone working on containerized-nerves. Seems like it could simplify operations and be portable between devices and data center.
For anyone interested in this thread/topic there was some discussion in the Elixir Slack nerves channel about a project to get this exact idea working with EC2 (by @jakemorrison):
I’ll definitely be following these projects intently.
This is working right now, though it’s just the base system. Next is using the EC2 metadata to configure the instance, e.g. set ssh keys. And then using cloud services for things like logging.