Building for fly, tailwind dependency breaks. What am I missing?

There are a lot of different files in the mix: Dockerfile, package.json, tailwind.config.json --and it all seems to be doing the right building, installing, and copying… but in the assets.build or assets.deploy step, the fly deploy docker build fails, unable to find the tailwindcss-animate dependency.

It all builds & runs locally.

The key docker file sequence is like so:


RUN npm install --prefix ./assets

COPY assets assets 

RUN mix deps.compile

COPY priv priv

COPY lib lib

# compile assets
RUN mix assets.setup
RUN mix assets.build
RUN mix assets.deploy

I added assets.setup and assets.build to the autogenerated Dockerfile, in case that was relevant. But it doesn’t make a difference.

The assets/package.json

  "main": "tailwind.config.js",
  "dependencies": {
    "tailwindcss-animate": "^1.0.7"
  },

The offending line in the tailwind config (commenting this out builds fine, but of course… it’s not going to run fine…

 plugins: [
    require("@tailwindcss/forms"),
    require("@tailwindcss/typography"),
    require("tailwindcss-animate"),

Note that its only tailwindcss-animate that fails, not the other dependencies.

Also, I am building without cacheing (I think?) using the command:

fly deploy --build-arg no-cache=true

Also note, I moved COPY assets assets up before mix deps.compile because mix deps.compile would fail on the missing tailwindcss-animate dependency if I left assets down where it was autogenerated. So… any & all tips welcome.

And to answer my own question with the Dockerfile that finally worked:

COPY assets assets 

RUN mix deps.compile

COPY priv priv

COPY lib lib

RUN npm install --prefix ./assets

# compile assets
RUN mix assets.deploy

I honestly don’t know why exactly this arrangement and sequence works while others do not, but such is the mystery of Docker (for me).