You seemed to have had problems with npm in the dev mode and used successfully pnpm to overcome this.
For the Dockerfile, you don't use pnpm and I assume it works.
If you want to match the code with the Dockerfile, you may want to use pnpmtoo.
For this, you need to install a recent Node.js version via cURL (Debian comes with v12 installed whilst pnpm requires >v16).
Note that node comes with npm.
You can use the Dockerfile below.
Note I optionally updated to the most recent Elixir version to match the Elixir 1.16 also optionally updated in the MixProject.
# see https://hub.docker.com/r/hexpm/elixir/tags?page=1
ARG ELIXIR_VERSION=1.16.2
^^^
ARG OTP_VERSION=25.3.2.10
^^^
ARG DEBIAN_VERSION=bullseye-20240130
^^^
ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}"
ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}"
FROM ${BUILDER_IMAGE} as builder
# install build dependencies (and curl for EXLA)
RUN apt-get update -y && apt-get install -y build-essential git curl -y libmagic-dev && \
curl -sL https://deb.nodesource.com/setup_18.x | bash - && \
^^^
apt-get install -y nodejs && \
apt-get clean && rm -f /var/lib/apt/lists/*_* && \
node --version && \
npm --version
RUN npm install -g pnpm
^^^
# 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 ./
RUN mix deps.get --only $MIX_ENV
RUN mkdir config
# copy compile-time config files before we compile dependencies
# to ensure any relevant config change will trigger the dependencies
# to be re-compiled.
COPY config/config.exs config/${MIX_ENV}.exs config/
RUN mix deps.compile
COPY priv priv
COPY lib lib
COPY assets assets
# Install dependencies for assets folder
RUN pnpm install --prefix assets
^^^
...
You seemed to have had problems with
npm
in the dev mode and used successfullypnpm
to overcome this.For the Dockerfile, you don't use
pnpm
and I assume it works.If you want to match the code with the Dockerfile, you may want to use
pnpm
too.For this, you need to install a recent
Node.js
version viacURL
(Debian comes with v12 installed whilstpnpm
requires >v16). Note thatnode
comes withnpm
.You can use the Dockerfile below.