rails / tailwindcss-rails

Other
1.37k stars 165 forks source link

Watcher not working in Docker even with `tty:true` #320

Closed dseravalli closed 5 months ago

dseravalli commented 6 months ago

The CSS is built successfully when I first docker-compose up but doesn't rebuild when I edit and save files.

Rails 7.0.4.3 tailwindcss-rails 2.0.29 MacOS Sonoma 14.2 Orbstack 1.3.0

tailwind.config.js content

  content: [
    './public/*.html',
    './app/helpers/**/*.rb',
    './app/javascript/**/*.js',
    './app/views/**/*.{erb,haml,html,slim}',
    './node_modules/flowbite/**/*.js',
  ],

docker-compose

version: '3.9'
services:
  app:
    tty: true
    build:
      context: .
      dockerfile: Dockerfile.dev
    ports:
      - '3001:3000'
    depends_on:
      - db
    volumes:
      - .:/app
    networks:
      - rails
...

Dockerfile.dev

...
CMD ["./bin/dev"]

Procfile.dev

web: bin/rails server -p 3000 -b 0.0.0.0
css: bin/rails tailwindcss:watch

/bin/dev

#!/usr/bin/env sh

if ! gem list foreman -i --silent; then
  echo "Installing foreman..."
  gem install foreman
fi

exec foreman start -f Procfile.dev "$@"
robacarp commented 5 months ago

I had some issues with this as well, and solved it by adding the puma module to puma.rb rather than running everything within foreman or running a dedicated compose container. However, it still required me to add tty: true to the compose entry for the rails server.

flavorjones commented 5 months ago

Sorry to hear you're having trouble with this feature. There are two other options you can try to use, which are documented in the README:

Please note that this gem doesn't implement the file watching; we're using the upstream tailwindcss executable's watch features for this. If you can't get it to work with either of these other options, you may want to ask for support upstream.