Created
May 24, 2016 17:50
-
-
Save gvarela/173d4427febab670da9a691b6bee48c9 to your computer and use it in GitHub Desktop.
Phoenix / Elixir Docerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM quay.io/aptible/alpine | |
############################################################################ | |
######################## Erlang setup ###################################### | |
############################################################################ | |
# Important! Update this no-op ENV variable when this Dockerfile | |
# is updated with the current date. It will force refresh of all | |
# of the base images and things like `apt-get update` won't be using | |
# old cached versions when the Dockerfile is built. | |
ENV REFRESHED_AT=2016-05-24 \ | |
LANG=en_US.UTF-8 \ | |
HOME=/app/ \ | |
# Set this so that CTRL+G works properly | |
TERM=xterm | |
# The app will exist in /app/user so it can be mounted as a volume | |
WORKDIR /app/user | |
# Install Erlang | |
RUN \ | |
mkdir -p ${HOME} && \ | |
adduser -s /bin/sh -u 1001 -G root -h ${HOME} -S -D default && \ | |
chown -R 1001:0 ${HOME} && \ | |
echo 'http://dl-4.alpinelinux.org/alpine/edge/main' >> /etc/apk/repositories && \ | |
echo 'http://dl-4.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories && \ | |
apk --no-cache upgrade && \ | |
apk-install ca-certificates \ | |
erlang erlang-dev erlang-kernel erlang-hipe erlang-compiler \ | |
erlang-stdlib erlang-erts erlang-syntax-tools erlang-sasl \ | |
erlang-crypto erlang-public-key erlang-ssl erlang-tools \ | |
erlang-inets erlang-mnesia erlang-odbc erlang-xmerl erlang-runtime-tools \ | |
erlang-erl-interface erlang-parsetools | |
############################################################################ | |
######################## Elixir / Phoenix setup ############################ | |
############################################################################ | |
# Install Elixir | |
RUN \ | |
apk --no-cache --update add \ | |
git make g++ wget curl \ | |
elixir=1.2.5-r0 \ | |
nodejs=6.2.0-r0 && \ | |
npm install npm -g --no-progress && \ | |
# update-ca-certificates --fresh && \ | |
rm -rf /var/cache/apk/* | |
# Add local node module binaries to PATH | |
ENV PATH ./node_modules/.bin:$PATH | |
# Install Hex and Rebar | |
RUN mix local.hex --force && \ | |
mix local.rebar --force | |
############################################################################ | |
######################## App setup ######################################## | |
############################################################################ | |
# Set exposed ports | |
EXPOSE 5000 | |
ENV PORT=5000 MIX_ENV=prod | |
# Same with elixir deps | |
ADD mix.exs mix.lock ./ | |
RUN mix do deps.get, deps.compile | |
# Cache 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"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment