Skip to content

Instantly share code, notes, and snippets.

@photomattmills
Last active August 29, 2015 14:26
Show Gist options
  • Save photomattmills/1fdab90bf43f68b4b703 to your computer and use it in GitHub Desktop.
Save photomattmills/1fdab90bf43f68b4b703 to your computer and use it in GitHub Desktop.
Dockerfile for running a phoenix app.
# Current debian stable for our base.
FROM debian:jessie
ENV LANG C.UTF-8
# Install base package, plus some Erlang deps
RUN apt-get update
RUN apt-get install -y wget git build-essential libwxbase3.0-0 libwxgtk3.0-0
# Install Erlang. This package is the current stable.
RUN wget http://packages.erlang-solutions.com/site/esl/esl-erlang/FLAVOUR_3_general/esl-erlang_18.0-1~debian~jessie_amd64.deb
RUN echo "78e4f920e39cb3cd49fc7fa1a81db1e9 esl-erlang_18.0-1~debian~jessie_amd64.deb" > sum.txt
RUN md5sum --check sum.txt
RUN dpkg -i esl-erlang_18.0-1~debian~jessie_amd64.deb
# Install Elixir
# Here we're working from master, you may want to do someting different. Bleeding
# edge is cool for demos, not for pord maybe.
WORKDIR /tmp/elixir-build
RUN git clone https://github.com/elixir-lang/elixir.git
# You don't need to run the tests, but it makes me feel better to do it.
WORKDIR elixir
RUN make clean test
RUN make install
## Prerequisites ##
RUN mix do local.rebar, local.hex --force
# This is the latest phoenix as of this writing.
RUN mix archive.install https://github.com/phoenixframework/phoenix/releases/download/v0.15.0/phoenix_new-0.15.0.ez
# Install python, so we can install node from source
RUN apt-get install -y python
# Install node from source because the packages don't work or are out of date.
# This step is pretty slow.
RUN wget https://nodejs.org/dist/v0.12.7/node-v0.12.7.tar.gz
RUN echo "6d59007212a964c7a4defc5520aedacdbcb008e1 *node-v0.12.7.tar.gz" > node_sum.txt
RUN sha1sum --check node_sum.txt
RUN tar -xvf node-v0.12.7.tar.gz
WORKDIR node-v0.12.7
RUN ./configure && make && make install
RUN rm -rf /tmp/elixir-build
## Fetch the phoenix application ##
WORKDIR /usr/local/lib
## Compile the app##
RUN git clone https://github.com/mattmills/live_phoenix_guides.git
WORKDIR live_phoenix_guides
# this app has a weird dependency; to get the guides to run, you have to clone them.
RUN git clone https://github.com/phoenixframework/phoenix_guides.git
RUN mix do deps.get
# Expose the port to the world, and set it as an environment variable for the app:
EXPOSE 4000
ENV PORT 4000
# install node dependencies
RUN npm install
# Set Environment variables for your app. Put a real secret key here maybe.
ENV MIX_ENV prod
ENV SECRET_KEY_BASE something_really_secret
# These steps are order dependent; the first creates the priv/static directory and
# compiles your CSS. The second moves other static assets into place, and compiles
# the app.
RUN ./node_modules/.bin/brunch build --production
RUN mix do compile, phoenix.digest web/static -o priv/static
# This is the single command that runs when you start the container. In this case,
# we're starting the phoenix server.
CMD ["elixir","-pa","_build/prod/consolidated","-S","mix","phoenix.server"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment