Setting up a phoneix project in a container , works fine on the cli
Dockerfile
FROM hexpm/elixir:1.11.2-erlang-23.1.3-debian-buster-20201012 AS base
# install build dependencies
RUN apt-get -qq update && \
apt-get -qq -y install build-essential npm git python --fix-missing --no-install-recommends
# prepare build dir
WORKDIR /app
ARG MIX_ENV
ARG RELEASE_LEVEL
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
# Update timezone
ENV TZ=Asia/Singapore
# install hex + rebar
RUN mix local.hex --force && \
mix local.rebar --force
# set build ENV
ENV MIX_ENV=$MIX_ENV
# install mix dependencies
COPY mix.exs mix.lock ./
COPY config config
RUN mix deps.get --only $MIX_ENV
RUN mix 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
RUN npm run --prefix ./assets deploy
RUN mix phx.digest
# compile and build release
COPY lib lib
# uncomment COPY if rel/ exists
# COPY rel rel
RUN mix do compile, release
FROM debian:buster-slim AS app
RUN apk add --no-cache openssl ncurses-libs
WORKDIR /app
ARG MIX_ENV
ARG RELEASE_LEVEL
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
# Update timezone
ENV TZ=Asia/Singapore
# Exposes port to the host machine
EXPOSE 8080
# Install stable dependencies that don't change often
RUN apt-get update && \
apt-get install -y --no-install-recommends \
apt-utils \
openssl \
curl \
wget && \
rm -rf /var/lib/apt/lists/*
RUN chown nobody:nobody /app
USER nobody:nobody
COPY --from=build --chown=nobody:nobody /app/_build/${MIX_ENV}/rel/ghost_rider ./
ENV HOME=/app
CMD ["bin/ghost_rider", "start"]
fails with following error
Step 15/35 : RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error
---> Running in 2b08ff3a7d3a
npm ERR! (intermediate value)(intermediate value)(intermediate value).then is not a function
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-12-02T02_23_33_826Z-debug.log
ERROR: Service 'ghost-rider' failed to build : The command '/bin/sh -c npm --prefix ./assets ci --progress=false --no-audit --loglevel=error' returned a non-zero code: 1
it works fine on the project via cli
npm --prefix ./assets ci --progress=false --no-audit --loglevel=error
.....
......
........
added 948 packages in 12.791s
deps
[
{:phoenix, "~> 1.5.7"},
{:phoenix_ecto, "~> 4.1"},
{:ecto_sql, "~> 3.4"},
{:ecto_psql_extras, "~> 0.2"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 2.11"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_live_dashboard, "~> 0.3 or ~> 0.2.9"},
{:telemetry_metrics, "~> 0.4"},
{:telemetry_poller, "~> 0.4"},
{:gettext, "~> 0.11"},
{:jason, "~> 1.0"},
{:plug_cowboy, "~> 2.0"},
{:finch, "~> 0.5.2"},
{:recaptcha, "~> 3.0"},
{:ink, "~> 1.0"},
{:credo, "~> 1.5", only: [:dev, :test], runtime: false},
{:sentry, "8.0.3"},
{:hackney, "~> 1.8"}
]