memEx/Dockerfile

55 lines
1.2 KiB
Docker
Raw Permalink Normal View History

2024-07-28 12:59:09 -04:00
FROM elixir:1.17.0-alpine AS build
2021-09-04 16:19:23 -04:00
# install build dependencies
RUN apk add --no-cache build-base npm git python3
# prepare build dir
WORKDIR /app
# install hex + rebar
2024-07-28 12:59:09 -04:00
RUN mix local.rebar --force && \
mix local.hex --force
2021-09-04 16:19:23 -04:00
# 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 lib lib
COPY priv priv
COPY assets assets
RUN npm run --prefix ./assets deploy
2022-02-13 15:50:48 -05:00
RUN mix do phx.digest, gettext.extract
2021-09-04 16:19:23 -04:00
# compile and build release
# uncomment COPY if rel/ exists
# COPY rel rel
RUN mix do compile, release
# prepare release image
2022-02-25 21:35:22 -05:00
FROM alpine:latest AS app
2021-09-04 16:19:23 -04:00
RUN apk upgrade --no-cache && \
2024-02-23 22:44:36 -05:00
apk add --no-cache bash openssl libssl3 libcrypto3 libgcc libstdc++ ncurses-libs
2021-09-04 16:19:23 -04:00
WORKDIR /app
RUN chown nobody:nobody /app
USER nobody:nobody
2022-07-25 19:31:54 -04:00
COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/memex ./
2022-02-25 21:35:22 -05:00
COPY --from=build --chown=nobody:nobody /app/priv /app/priv
RUN chmod +x /app/priv/random.sh
2021-09-04 16:19:23 -04:00
ENV HOME=/app
2022-07-25 19:31:54 -04:00
CMD ["bin/memex", "start"]