An Alpine Linux base image containing Elixir, Erlang, Node, Hex, and Rebar. Ready for Phoenix applications!
Latest commit c18fb01 Jan 13, 2017 @bitwalker Version 1.4.0
Failed to load latest commit information.
Dockerfile Version 1.4.0 Jan 13, 2017
LICENSE Initial commit Jan 8, 2016
Makefile Update docker build to tag :latest Apr 8, 2016 Update README Oct 10, 2016
VERSION Version 1.4.0 Jan 13, 2017

Elixir/Phoenix on Alpine Linux

This Dockerfile provides everything you need to run your Phoenix application in Docker out of the box.

It is based on my alpine-erlang image, and installs Elixir (1.3.x), Node.js (6.2.x), Hex and Rebar. It can handle compiling your Node and Elixir dependencies as part of it's build.


NOTE: This image is intended to run in unprivileged environments, it sets the home directory to /opt/app, and makes it globally read/writeable. If run with a random, high-index user account (say 1000001), the user can run an app, and that's about it. If run with a user of your own creation, this doesn't apply (necessarily, you can of course implement the same behaviour yourself). It is highly recommended that you add a USER default instruction to the end of your Dockerfile so that your app runs in a non-elevated context.

To boot straight to a prompt in the image:

$ docker run --rm -it --user=1000001 bitwalker/alpine-elixir-phoenix iex
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false]

Interactive Elixir (1.2.4) - press Ctrl+C to exit (type h() ENTER for help)
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution

Extending for your own application:

FROM bitwalker/alpine-elixir-phoenix:latest

# Set exposed ports
ENV PORT=5000 MIX_ENV=prod

# Cache elixir deps
ADD mix.exs mix.lock ./
RUN mix do deps.get, deps.compile

# Same with npm deps
ADD package.json package.json
RUN npm install

ADD . .

# Run frontend build, compile, and digest assets
RUN brunch build --production && \
    mix do compile, phoenix.digest

USER default

CMD ["mix", "phoenix.server"]

It is recommended when using this that you have the following in .dockerignore when running docker build:


This will keep the payload smaller and will also avoid any issues when compiling dependencies.