Created
October 17, 2019 08:09
-
-
Save benyblack/9e6a1ed90480111f270f23905f049955 to your computer and use it in GitHub Desktop.
Elixir Phoenix helloworld Dockerfile
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
########################################################################### | |
# Based on https://gist.github.com/teamon/27ed7e551d188930c9fa0b5e19bd76b7# | |
########################################################################### | |
FROM node:latest as build-node | |
# prepare build dir | |
RUN mkdir -p /app/assets | |
WORKDIR /app | |
# set build ENV | |
ENV NODE_ENV=dev | |
# install npm dependencies | |
COPY assets/package.json assets/package-lock.json ./assets/ | |
COPY deps/phoenix deps/phoenix | |
COPY deps/phoenix_html deps/phoenix_html | |
RUN cd assets && npm install | |
# build assets | |
COPY assets ./assets/ | |
RUN cd assets && npm run deploy | |
FROM elixir:latest | |
LABEL authur=benyblack | |
ENV MIX_ENV=dev | |
ENV PORT=4000 | |
# COPY . /app | |
RUN mkdir /app | |
WORKDIR /app | |
RUN mix local.hex --force | |
RUN mix local.rebar --force | |
# install dependencies | |
COPY mix.exs mix.lock ./ | |
RUN mix deps.get | |
# compile dependencies | |
COPY config ./config/ | |
RUN mix deps.compile | |
# copy only elixir files to keep the cache | |
COPY lib ./lib/ | |
COPY priv ./priv/ | |
# copy assets from node build | |
COPY --from=build-node /app/priv/static ./priv/static | |
RUN mix phx.digest | |
EXPOSE ${PORT} | |
ENTRYPOINT ["mix", "phx.server"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment