2023-02-27 11:16:01 +00:00
|
|
|
FROM elixir:1.12-alpine AS build
|
2021-08-13 08:42:49 +00:00
|
|
|
|
|
|
|
# install build dependencies
|
2021-08-16 21:52:52 +00:00
|
|
|
RUN apk add --no-cache build-base npm git curl py-pip rust cargo
|
2021-08-13 08:42:49 +00:00
|
|
|
|
|
|
|
# prepare build dir
|
|
|
|
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 do deps.get, deps.compile
|
|
|
|
|
|
|
|
# build assets
|
|
|
|
COPY assets/package.json assets/package-lock.json ./assets/
|
|
|
|
RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error
|
|
|
|
|
|
|
|
COPY priv priv
|
|
|
|
COPY assets assets
|
2021-08-14 09:48:55 +00:00
|
|
|
COPY lib lib
|
2021-08-16 21:52:52 +00:00
|
|
|
COPY native native
|
2021-08-13 08:42:49 +00:00
|
|
|
RUN npm run --prefix ./assets deploy
|
|
|
|
RUN mix phx.digest
|
|
|
|
|
|
|
|
# uncomment COPY if rel/ exists
|
|
|
|
# COPY rel rel
|
|
|
|
RUN mix do compile, release
|
|
|
|
|
|
|
|
# prepare release image
|
|
|
|
FROM alpine:3.9 AS app
|
|
|
|
RUN apk add --no-cache openssl ncurses-libs libstdc++
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
RUN chown nobody:nobody /app
|
|
|
|
|
|
|
|
USER nobody:nobody
|
|
|
|
|
|
|
|
COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/ketbin ./
|
|
|
|
|
2021-08-13 19:49:00 +00:00
|
|
|
COPY --chown=nobody:nobody startup.sh startup.sh
|
|
|
|
|
|
|
|
RUN chmod +x /app/startup.sh
|
|
|
|
|
2021-08-13 08:42:49 +00:00
|
|
|
ENV HOME=/app
|
|
|
|
|
2023-02-27 11:13:57 +00:00
|
|
|
CMD ["/app/startup.sh"]
|