1 min read

Adding bin/dev to your pre Rails 7 application

I recently wrote a bit about using the new bin/dev script in your Rails 7 application and figured I’d do a quick video on how to get a bin/dev script added to your pre-rails 7 application.

The bin/dev script is part of the cssbundling-rails gem but what you end up with is pretty simple to add without needing to go through the setup process.

Once you have a bin/dev script within your Rails application it should make setting up a new app as simple as:

  1. git clone
  2. bin/setup
  3. bin/dev

Here are the scripts I utilized in the video as well.

bin/dev:

#!/usr/bin/env sh -eux

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

exec foreman start -f Procfile.dev

Procfile.dev:

web: bundle exec puma -C config/puma.rb
db: docker compose up mysql

docker-compose.yml:

version: "3"
services:
  mysql:
    image: mysql:8.0.32
    ports:
      - "3306:3306"
    environment:
      - MYSQL_ROOT_PASSWORD=root