cannery/Dockerfile
shibao e358cd6e4e
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
downgrade versions until hex is supported in build
2024-06-16 12:13:34 -04:00

55 lines
1.2 KiB
Docker

FROM elixir:1.16.3-otp-26-alpine AS build
# install build dependencies
RUN apk add --no-cache build-base npm git python3
# 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 lib lib
COPY priv priv
COPY assets assets
RUN npm run --prefix ./assets deploy
RUN mix do phx.digest, gettext.extract
# compile and build release
# uncomment COPY if rel/ exists
# COPY rel rel
RUN mix do compile, release
# prepare release image
FROM alpine:latest AS app
RUN apk upgrade --no-cache && \
apk add --no-cache bash openssl libssl3 libcrypto3 libgcc libstdc++ ncurses-libs
WORKDIR /app
RUN chown nobody:nobody /app
USER nobody:nobody
COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/cannery ./
COPY --from=build --chown=nobody:nobody /app/priv /app/priv
RUN chmod +x /app/priv/random.sh
ENV HOME=/app
CMD ["bin/cannery", "start"]