Re:Rails on Docker · Fly
by brightball on Thursday January 26, 2023 @03:31PM
(#34538336)
Yea, typically I just do the step manually to start dependencies and then start the rails processes.
Re:Rails on Docker · Fly
by markhesketh on Thursday January 26, 2023 @05:06PM
(#34539563)
I do the same thing and it works well.
For your issue could you handle bringing up your docker-compose 'manually' in bin/dev? Maybe conditionally by checking if the image exists locally with `docker images`. Then tear it down and run foreman after it completes?
If anyone is curious about the details, I simply reused the existing `bin/dev` script set up by Rails by adding this to `Procfile.dev`:
The only issue is that foreman (the gem used by `bin/dev` to start multiple processes) doesn't have a way to mark one process as depending on another, so this relies on Docker starting the Postgres and Redis containers fast enough so that they're up and running for Rails and Sidekiq. In practice it means that we need to run the `docker compose` manually the first time (and I suppose every time we'll update to new versions) so that Docker downloads the images and caches them locally.