Skip to content

Missing class from precompiled output after building with Docker #546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
omegahm opened this issue May 7, 2025 · 2 comments
Closed

Missing class from precompiled output after building with Docker #546

omegahm opened this issue May 7, 2025 · 2 comments

Comments

@omegahm
Copy link

omegahm commented May 7, 2025

I have a brand new Rails (8.0.2) project with Ruby 3.4.2:

$ rails new ThisAndThat --css tailwind --js importmap --database sqlite3

I add a div with a class of max-h-8 to the layout/application.html.erb file.
If I now run tailwindcss binary, I get:

$ bundle exec tailwindcss --input app/assets/tailwind/application.css -o - | grep "max-h-8"
≈ tailwindcss v4.1.5
  .max-h-8 {
Done in 39ms

This works. So it shows in my local development just fine.

I now want to deploy my project with a Docker image. I run:

$ docker buildx build --progress plain --platform linux/amd64/v2 --tag thisandthat --load .

which builds me a Docker image. I build with that platform argument, because I am on an M2 MacBook and want to run the Docker image on a Ubuntu server.

I launch an interactive shell with:

$ docker run -it --rm thisandthat bash

and look at the compiled Tailwind CSS for the class max-h-8:

$ cat public/assets/tailwind-* | grep "max-h-8"

This comes up empty! 🚫

If I do the same with another class, say z-auto, or even max-h-[8px] it works flawlessly.

What am I missing?

@omegahm
Copy link
Author

omegahm commented May 7, 2025

Installing Node and npm in the same Docker image and trying compiling the CSS yields the correct results.

I've installed Node and npm by adding the following after the assets:precompile step in Dockerfile.

RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
ENV NVM_DIR=/root/.nvm
RUN bash -c "source $NVM_DIR/nvm.sh && nvm install 23"
RUN bash -c "source $NVM_DIR/nvm.sh && npm install tailwindcss @tailwindcss/cli"
RUN bash -c "source $NVM_DIR/nvm.sh && npx @tailwindcss/cli -i app/assets/tailwind/application.css -o - | grep \"max-h-8\""

@omegahm
Copy link
Author

omegahm commented May 7, 2025

I see this is a duplicate of tailwindlabs/tailwindcss#17728 and #534. I'll follow along there instead and close this issue.

@omegahm omegahm closed this as completed May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant