diff --git a/Dockerfile b/Dockerfile index 4c2e715b..f04e521b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,18 @@ # --- Set up Elixir build --- -FROM hexpm/elixir:1.15.7-erlang-26.1.2-debian-bullseye-20231009-slim as elixir-builder +FROM hexpm/elixir:1.15.7-erlang-26.1.2-alpine-3.18.4 as elixir-builder ENV LANG=C.UTF-8 MIX_ENV=prod -RUN apt-get update --allow-releaseinfo-change -RUN apt-get install --no-install-recommends --yes \ - build-essential ca-certificates git +RUN apk add --no-cache \ + git RUN mix local.hex --force RUN mix local.rebar --force WORKDIR /root -ADD . . +COPY ./mix.exs mix.exs +COPY ./mix.lock mix.lock RUN mix deps.get --only prod +RUN mix deps.compile # --- Build Elixir release --- @@ -20,6 +21,10 @@ FROM elixir-builder as app-builder ENV LANG=C.UTF-8 MIX_ENV=prod WORKDIR /root +COPY ./assets assets +COPY ./config config +COPY ./lib lib +COPY ./priv priv RUN mix compile RUN mix assets.deploy RUN mix phx.digest @@ -27,13 +32,12 @@ RUN mix release # --- Set up runtime container --- -FROM debian:bullseye-slim +FROM alpine:3.18.4 ENV LANG=C.UTF-8 MIX_ENV=prod REPLACE_OS_VARS=true -RUN apt-get update --allow-releaseinfo-change \ - && apt-get install --no-install-recommends --yes dumb-init wget \ - && rm -rf /var/lib/apt/lists/* +RUN apk add --no-cache \ + dumb-init libgcc libstdc++ ncurses-libs # Create non-root user RUN addgroup --system mobileappbackend && adduser --system --ingroup mobileappbackend mobileappbackend