Add documentation about running watch command in `docker-compose.yml` as a sidecar
joshuadavidthomas opened this issue Β· comments
Firstly, thanks so much for this package! π It has really helped simplify our dev stack by (mostly) removing the need to have Node installed just to use Tailwind.
I do have a small suggestion for documentation improvements.
I have been playing with running python manage.py tailwind watch
as a sidecar container in our dev docker-compose.yml
file to take care of auto-rebuilding the CSS without having to run the command myself.
At first this wasn't working, either in a dedicated tailwind
container using the above command or in the main django
container using the python manage.py tailwind runserver
command. The dedicated container would just quit immediately after starting -- with no log output to help debug what was going on -- or in the main container the runserver
command would start the development server and no CSS was rebuilt with no logs as well.
I even skipped using this package and ran the Tailwind cli directly using the same arguments this package uses to the same effect of the container quitting immediately.
I was tearing my hair out trying out trying to chase down what was going on -- hard to do with no logs π -- and I stumbled across some issues related to the issue in regards to the rails package:
Adding tty: true to the compose file that the tailwindcss:watch process is running in will prevent the immediate exit.
https://github.com/rails/tailwindcss-rails#update-assets-automatically
If you are running rails tailwindcss:watch as a process in a Docker container, set tty: true in docker-compose.yml for the appropriate container to keep the watch process running.
Looks to be an issue with the Tailwind cli binary in watch mode expecting to be run in a TTY. Sure enough, adding tty: true
to the service definition in my docker-compose.yml
fixed the issue and the sidecar container is able to start and stay running while rebuilding the CSS in the background.
I don't mind writing up something and submitting a PR for this myself, but I wasn't sure where you would want something like this. I assume somewhere in the "Usage" section, but I'll leave that up to you. π
Oh, this is an interesting piece of information. I just gave it a try to fully understand it as I don't use dev containers or anything myself. This would be very handy as an information and the "usage" section seems to a good place for it. I would be happy to merge a pull request for this.