Skip to content

Instantly share code, notes, and snippets.

@christopherlai
Created September 16, 2019 22:57
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christopherlai/0503bee142b6fe1b64f0496376c3ea98 to your computer and use it in GitHub Desktop.
Save christopherlai/0503bee142b6fe1b64f0496376c3ea98 to your computer and use it in GitHub Desktop.
Example Dockerfile for Elixir 1.9.1 umbrella project
FROM elixir:1.9.1-alpine as build
ENV MIX_ENV=prod
WORKDIR /build
RUN apk add --no-cache build-base nodejs yarn && \
mix local.hex --force && \
mix local.rebar --force
COPY mix.exs mix.lock config/ ./
COPY apps/web/mix.exs ./apps/web/
COPY apps/database/mix.exs ./apps/database/
RUN mix deps.get --only prod && \
mix deps.compile
COPY . .
RUN yarn --cwd apps/web/assets install --pure-lockfile && \
yarn --cwd apps/web/assets deploy && \
cd apps/web && mix phx.digest
RUN mix release
FROM elixir:1.9.1-alpine
RUN addgroup -S release && \
adduser -S -G release release && \
mkdir /release && \
chown -R release: /release
WORKDIR /release
COPY --from=build --chown=release:release /build/_build/prod/rel/projectx .
USER release
EXPOSE 4000
CMD ["bin/projectx", "start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment