-
-
Save tporto/aeeeee2e93de02e48249efe832f5a7e2 to your computer and use it in GitHub Desktop.
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
FROM hexpm/elixir:1.11.2-erlang-23.1.2-alpine-3.12.1 as build | |
# install build dependencies | |
RUN apk add --update git build-base npm nodejs python3 | |
# prepare build dir | |
RUN mkdir /app | |
WORKDIR /app | |
# install hex + rebar | |
RUN mix local.hex --force && \ | |
mix local.rebar --force | |
# set build ENV | |
ENV MIX_ENV=prod | |
# install mix dependencies | |
COPY mix.exs mix.lock ./ | |
COPY config config | |
RUN mix deps.get | |
RUN mix deps.compile | |
# build assets | |
COPY assets assets | |
COPY priv priv | |
RUN cd assets && npm install && npm run deploy | |
RUN mix phx.digest | |
# build project | |
COPY lib lib | |
RUN mix compile | |
# build release (uncomment COPY if rel/ exists) | |
# COPY rel rel | |
RUN mix release | |
# prepare release image | |
FROM alpine:3.12 AS app | |
RUN apk add --update bash openssl | |
RUN mkdir /app | |
WORKDIR /app | |
ENV HOME=/app | |
COPY --from=build /app/_build/prod/rel/<YOUR_APP_NAME> ./ | |
COPY entrypoint.sh ./ | |
RUN ["chmod", "+x", "/app/entrypoint.sh"] | |
RUN chown -R nobody: /app | |
USER nobody | |
CMD ["./entrypoint.sh"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment