We are beginning to work with Phoenix/Elixir and I am tasked with deploy strategy. I did some searching and came across this article on deploying to AWS Elastic Beanstalk and all was well when we were messing with Phoenix 1.2.x and then we made the switch to version 1.3.0. I have made all the necessary updates to the Dockerfile and .dockerignore that have to do with new directory structures. I can get the deployment to work for the initial deploy and even a few after that, but if I try the next day I get Permission denied
when it tries to run the brunch command.
I am including my Dockerfile and .dockerignore to see if I am missing something important.
Dockerfile
# Set the Docker image you want to base your image off.
# I chose this one because it has Elixir preinstalled.
FROM trenpixster/elixir:1.4.4
# Set the locale, otherwise elixir will complain later on
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
# Setup Node - Phoenix uses the Node library `brunch` to compile assets.
# The official node instructions want you to pipe a script from the
# internet through sudo. There are alternatives:
# https://www.joyent.com/blog/installing-node-and-npm
RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - && sudo apt-get install -y nodejs
#Install other stable dependencies that don't change often
#
# Compile app
RUN mkdir /app
WORKDIR /app
# Install Elixir Deps
ADD mix.* ./
RUN MIX_ENV=prod mix local.rebar
RUN MIX_ENV=prod mix local.hex --force
RUN MIX_ENV=prod mix deps.get
# Install Node Deps
WORKDIR /app/assets
ADD ./assets/package* ./assets/
RUN npm install
WORKDIR /app
# Install app
ADD . .
RUN MIX_ENV=prod mix compile
# Compile assets
RUN NODE_ENV=production assets/node_modules/brunch/bin/brunch build --production
WORKDIR /app
RUN MIX_ENV=prod mix phx.digest
# Exposes this port from the docker container to the host machine
EXPOSE 4000
# The command to run when this image starts up
CMD MIX_ENV=prod mix ecto.create && \
MIX_ENV=prod mix ecto.migrate && \
MIX_ENV=prod mix phx.server
----------
.dockerignore
----------
/deps
/_build
ecl_Crash.dump
/assets/node_modules
/priv/static/*
/uploads/files/*
.git
.gitignore
# Elastic Beanstalk Files
.elasticbeanstalk/*