Elixir Getting Started Guide

Hi,

I have been following the guide and have an issue. I am using esbuiild and also npm. I am using npm to run a deploy script to minify my css and tailwindcss.

In the `package.json’ I have


"deploy": "NODE_ENV=production tailwindcss --postcss --minify --input=css/app.css --output=../priv/static/assets/app.css"

In my mix.exs I have

"assets.deploy": [
        "cmd --cd assets npm run deploy",
        "esbuild default --minify",
        "phx.digest"
      ]

When I run fly deploy I get the error

sh: 1: npm: not found
** (exit) 127
    (mix 1.12.3) lib/mix/tasks/cmd.ex:64: Mix.Tasks.Cmd.run/1
    (mix 1.12.3) lib/mix/task.ex:394: anonymous fn/3 in Mix.Task.run_task/3
    (mix 1.12.3) lib/mix/task.ex:452: Mix.Task.run_alias/5
    (mix 1.12.3) lib/mix/cli.ex:84: Mix.CLI.run_task/2

Error error building: error rendering build status stream: The command '/bin/sh -c mix assets.deploy' returned a non-zero code: 1

Initially I thought I could add nodejs and nodejs-npm to the Dockerfile

RUN apt-get update -y && apt-get install -y libstdc++6 openssl libncurses5 locales nodejs nodejs-npm \
  && apt-get clean && rm -f /var/lib/apt/lists/*_*

I re-ran fly launch but get the same error. Does anyone know how I can change the config to work?

UPDATE: I had the install of node and npm on the RUNNER image instead of the builder image. so now I have updated theDockerfile

# install build dependencies
RUN apt-get update -y && apt-get install -y build-essential git npm \
    && apt-get clean && rm -f /var/lib/apt/lists/*_*

This now works but does not build the minified css (i.e. no tailwindcss on the running application).

I will keep debugging but if anyone has any guidance it will be appreciated.

Thanks,

Andrew

UPDATE: See below