Phoenix On A Raspberry Pi with Exrm

March 30, 2016

Reading time ~2 minutes


Before you read this be sure to look at:

  1. Phoenix Advanced Deployment
  2. Exrm Docs

And if you really have ton of time then learn ye some Erlang

If you write Elixir and if you question things, then at some point you realize that you need to learn some of Erlang with its OTP.

Elixir is like a Coffee-Script for the JavaScript world but with much better support and you almost never need to touch Erlang.

Until you want to do some cool stuff like cross-compiled deploys.

Deploying your Elixir App onto ARM-Linux device with Exrm

I have a Raspberry Pi 1 running OSMC a linux system. I want to run Phoenix application on that box just for fun.

Exrm and Phoenix Docs describe deploy process thoroughly but it works for systems with Erlang pre-installed.

In order to run an app on a system without

binaries you’d have to build cross compiled version of erlang specifically for that system (in my case that’s ARM-linux OSMC).

I failed to do build it manually on OSX. I had to install

with help of Erlang Embedded guys.

Just follow this post to install erlang on your Pi.

You will get erlang build installed in

you can copy that folder to convenient location

That folder is useful for all further deploys to any Pi

You still would need to tell Exrm about specific libs before running release. Libs and erts of Erlang built for Pi (

Configure relx

So these are the steps:

Generate a new Application

$ mix help --no-brunch

Check if it works locally

$ cd pi
$ mix phoenix.server

Install exrm

# in mix.exs
defp deps do
  [ ..., {:exrm, "~> 1.0.3"}]
$ mix deps.get

Configure relx

$ mkdir -p rel
$ echo '{include_erts, "/Volumes/Disk/erlang"}.' >> rel/relx.config
$ echo '{system_libs, "/Volumes/Disk/erlang/lib"}.' >> rel/relx.config

Replace /Volumes/Disk/erlang with a path to the erts extracted from the pi

Compile the app for prod and build a release

$ MIX_ENV=prod mix phoenix.digest &&\
  MIX_ENV=prod mix compile &&\
  MIX_ENV=prod mix release

Test it:

$ scp rel/pi/releases/0.0.1/pi.tar.gz tv:~
$ ssh tv
$ cd ~ && mkdir -p app && tar -xzf pi.tar.gz -C ./app

For details see Phoenix on Pi repo

Please dm me on twitter Andrew Shatnyy in case there’re questions. English is my second language and I am sure this guide could make no sense to a native speaker :)

Wait in generator functions or how to mock a request in ES6

Testing requests with generator functions ES6 styleI was implementing an async retrier while refactoring some callback hell.And while tes...… Continue reading

XhrHttpRequest Webworker from the function

Published on December 20, 2015