Last active
April 8, 2019 15:51
-
-
Save felix-d/6acfe282998543f6a8e77de4acab734d to your computer and use it in GitHub Desktop.
Elixir Phoenix Distillery Multi-Stage 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
# Assets compilation | |
FROM aparedes/alpine-node-yarn as node | |
## Node modules | |
COPY ./deps /tmp/deps | |
COPY ./assets/package.json /tmp/deps | |
COPY ./assets/package-lock.json /tmp/deps | |
WORKDIR /tmp/deps | |
RUN yarn | |
## Assets compilation | |
COPY ./assets /tmp/assets | |
RUN cp -R /tmp/deps/node_modules /tmp/assets | |
WORKDIR /tmp/assets | |
RUN ./node_modules/.bin/brunch build --production | |
# Distillery release | |
FROM bitwalker/alpine-elixir as distillery | |
ARG APP_NAME=web | |
ENV MIX_ENV prod | |
COPY . /app | |
COPY --from=node /tmp/priv/static /app/priv/static | |
WORKDIR /app | |
RUN mix phx.digest && mix release --env=prod | |
RUN mkdir target | |
RUN tar xzf ./_build/prod/rel/$APP_NAME/releases/*/$APP_NAME.tar.gz -C ./target | |
# Final image | |
FROM alpine:latest | |
RUN apk add --update openssl bash && \ | |
rm -rf /var/cache/apk/* | |
COPY --from=distillery /app/target /app | |
ENV PORT 4000 | |
WORKDIR /app | |
CMD ["./bin/web", "foreground", "--sname", "web", "--cookie", "secret"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment