Last active
June 19, 2019 14:59
-
-
Save wmnnd/dfc888e965a877e247a7c8f5ad3dab1c to your computer and use it in GitHub Desktop.
Elixir Dockerfile Boilerplate
This file contains hidden or 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
#=========== | |
#Build Stage | |
#=========== | |
FROM bitwalker/alpine-elixir:1.5 as build | |
#Copy the source folder into the Docker image | |
COPY . . | |
#Install dependencies and build Release | |
RUN export MIX_ENV=prod && \ | |
rm -Rf _build && \ | |
mix deps.get && \ | |
mix release | |
#Extract Release archive to /rel for copying in next stage | |
RUN APP_NAME="MY_APP_NAME" && \ | |
RELEASE_DIR=`ls -d _build/prod/rel/$APP_NAME/releases/*/` && \ | |
mkdir /export && \ | |
tar -xf "$RELEASE_DIR/$APP_NAME.tar.gz" -C /export | |
#================ | |
#Deployment Stage | |
#================ | |
FROM pentacent/alpine-erlang-base:latest | |
#Set environment variables and expose port | |
EXPOSE 4000 | |
ENV REPLACE_OS_VARS=true \ | |
PORT=4000 | |
#Copy and extract .tar.gz Release file from the previous stage | |
COPY --from=build /export/ . | |
#Change user | |
USER default | |
#Set default entrypoint and command | |
ENTRYPOINT ["/opt/app/bin/MY_APP_NAME"] | |
CMD ["foreground"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment