Skip to content

Instantly share code, notes, and snippets.

@dealloc
Created March 15, 2021 15:27
Show Gist options
  • Save dealloc/2e842d3ed07fe680b7b11c1623d9f5e4 to your computer and use it in GitHub Desktop.
Save dealloc/2e842d3ed07fe680b7b11c1623d9f5e4 to your computer and use it in GitHub Desktop.
Phoenix Dockerfile
_build/
.elixir_ls/
assets/node_modules/
deps/
priv/static
FROM elixir:1.11-alpine as build
ENV MIX_ENV=prod
WORKDIR /tmp/tprofile
RUN mix local.hex --force && mix local.rebar --force
COPY mix.exs mix.lock ./
RUN mix do deps.get --only prod
FROM node:15-alpine as frontend
WORKDIR /tmp/tprofile_front
COPY --from=build /tmp/tprofile/deps/phoenix/ ./deps/phoenix/
COPY --from=build /tmp/tprofile/deps/phoenix_html/ ./deps/phoenix_html/
COPY --from=build /tmp/tprofile/deps/phoenix_live_view/ ./deps/phoenix_live_view/
COPY assets/ ./assets/
RUN npm ci --progress=false --no-audit --loglevel=error --prefix assets
ENV NODE_ENV=production
RUN npm run deploy --prefix assets
FROM build as release
COPY config ./config
COPY lib ./lib
COPY priv ./priv
COPY --from=frontend /tmp/tprofile_front/priv/static ./priv/static/
RUN mix do phx.digest, compile, release
FROM alpine:3.13 as app
WORKDIR /app
RUN chown -R nobody:nobody /app
RUN apk add --no-cache openssl ncurses-libs
USER nobody:nobody
COPY --from=release --chown=nobody:nobody /tmp/tprofile/_build/prod/rel/tprofile ./
ENV HOME=/app
CMD ["bin/tprofile", "start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment