Docker configuration for running an Elixir server
docker run --name my-elixir-server \
-v /path/to/mix/folder:/app \
-d madnificent/elixir-server
This will get all dependencies, compile them and run a production-build of your server with mix server
.
The commands boild down to:
MIX_ENV=prod mix do deps.get, compile
MIX_ENV=prod mix compile.protocols
MIX_ENV=prod elixir -pa _build/prod/consolidated -S mix run --no-halt
You can set the following arguments:
IEX_COOKIE
sets the default cookie for connectingIEX_NAME
sets the name for connecting (@ip will be replaced by the docker's ip address)IEX_PORT
forces running the node on a particular port (eg: 9000)LOG_ELIXIR_STARTUP_COMMAND
Logs the command by which the service will be booted up and the IP address of the container when non-empty (handy for connecting to the node)
The combination of these allows you to connect another erlang node to this one. See http://benjamintan.io/blog/2014/05/25/connecting-elixir-nodes-on-the-same-lan/