Rails development with Redis server dump.rbd file in different directory

December 06, 2023

Redis in development


Quick note for my future self :) During Rails development for my sideproject DrawColors, I've added Redis to the stack. To make it easy on myself, the server starts when running bin/dev, by adding redis-server to the Procfile.dev.
Redis stores the database dump on the disk, in a dump.rdb file. Annoyingly that's stored in the app root directory. I don't want that and don't want to commit it into git either, so previously added it to the .gitignore file.


Move Redis dump.rdb file
A way easier solution is to move the dump.rdb file to a different directory. Redis supports this by adjusting the redis.conf file. BUT, that's another file which feels like "overhead" and since I'm using the Procfile.dev to start the server.... Could we update the command when starting the redis-server?
YES ... WE ... CAN!

Update Procfile.dev
redis: redis-server --dir /tmp


And voila! The dump.rdb file is now stored in the /tmp directory.

Share

Do you have other tips and tricks for your Rails apps or local development environment? Please share them with me on Twitter or LinkedIn. I'm happy to learn from you.