This repo is the Rails backend / admin for the project.
These steps assume macOS, Linux, or WSL; everyone should be able to follow the same flow.
We support two development workflows:
- Docker-based development (recommended for consistency)
- Local development (using
asdfand local PostgreSQL)
We standardize on:
- Ruby 3.4.4 and Node.js 20.0.0
- PostgreSQL as the database
- Yarn 4 (Plug'n'Play) for JavaScript dependencies
This approach uses Docker Compose to run both the Rails app and PostgreSQL in containers, ensuring a consistent development environment across all machines.
- Docker Desktop (or Docker Engine + Docker Compose)
- macOS: Docker Desktop for Mac
- Linux: Install
dockeranddocker-composevia your package manager - Windows: Docker Desktop for Windows or WSL2
-
Ensure database configuration exists:
If
config/database.ymldoesn't exist, create it from the example:cp config/database.example.yml config/database.yml
The Docker setup uses environment variables (
DB_HOST=db), so the default configuration will work. -
Start the Docker services:
docker compose up -d
This will:
- Build the development Docker image (first time only, takes a few minutes)
- Start PostgreSQL database container
- Start the Rails app container (runs entrypoint script automatically)
- The entrypoint script waits for the database, creates it if needed, runs migrations, and builds JS assets
-
Verify everything is running:
docker compose ps
Both
webanddbservices should show as "Up". -
Access the Rails container:
docker compose exec web bashYou're now inside the container with all dependencies installed. The database has been created and migrated automatically.
Option A: Run Rails server only
docker compose exec web bin/rails server -b 0.0.0.0Visit: http://localhost:3000
Option B: Run with JS watcher (recommended for active development)
In one terminal, start the Rails server:
docker compose exec web bin/rails server -b 0.0.0.0In another terminal, start the JS watcher:
docker compose exec web yarn build --watchOption C: Run both with foreman (inside container)
docker compose exec web bin/dev-
View logs:
docker compose logs -f web # Rails app logs docker compose logs -f db # Database logs
-
Run Rails console:
docker compose exec web bin/rails console -
Run tests:
docker compose exec web bundle exec rspec
-
Rebuild JavaScript assets:
docker compose exec web yarn build -
Run database migrations:
docker compose exec web bin/rails db:migrate -
Stop services:
docker compose down
-
Stop and remove volumes (clean slate):
docker compose down -v
-
Rebuild the Docker image (after Dockerfile changes):
docker compose build --no-cache
- Code changes: Your local code is mounted as a volume, so changes are immediately reflected in the container (no rebuild needed).
- Dependencies: Ruby gems and Node modules are cached in Docker volumes for faster rebuilds.
- Database: PostgreSQL data persists in a Docker volume (
postgres-data). - Ports:
- Rails app:
http://localhost:3000 - PostgreSQL:
localhost:5433(mapped from container port 5432, if you need direct DB access)
- Rails app:
- Container won't start:
- Check logs with
docker compose logs web - If you see migration errors, the container will still start but migrations may need manual fixing
- Rebuild the container after changing
docker-entrypoint.sh:docker compose build web
- Check logs with
- Database connection errors: Ensure the
dbservice is healthy:docker compose ps - Migration errors:
- The entrypoint script will warn but not fail if migrations have issues
- You can run migrations manually:
docker compose exec web bundle exec rails db:migrate - If migrations fail due to missing tables, you may need to run them in a specific order or fix the migration files
- Permission errors: On Linux, you may need to fix file permissions:
sudo chown -R $USER:$USER .
- Port already in use:
- If port 5432 is in use (local PostgreSQL), the Docker setup uses port 5433 instead
- If port 3000 is in use, change it in
docker-compose.yml:"127.0.0.1:3001:3000"
- Need to reset everything:
docker compose down -v && docker compose up -d
If you prefer to run everything locally without Docker, follow these steps:
- Git
- PostgreSQL (local install or via Docker)
asdfinstalled and initialized in your shell- After installation, in a new terminal,
asdf --versionshould work.
- After installation, in a new terminal,
- Node/Yarn (managed by
asdfand Corepack as described below)
This repo includes .tool-versions:
ruby 3.4.4
nodejs 20.0.0
Install the plugins (once per machine):
asdf plugin add ruby || true
asdf plugin add nodejs || trueInstall the versions for this project:
asdf install # reads .tool-versions
asdf current # should show ruby 3.4.4 and nodejs 20.0.0Confirm Ruby:
ruby -v # should report 3.4.4If Ruby still reports a different version, ensure asdf is initialized in your shell
per the asdf docs, then open a new terminal and run the above again.
Create a development database config based on the example:
cp config/database.example.yml config/database.yml-
If you use local PostgreSQL, edit
config/database.ymland set:host: localhost
-
If you use Docker / devcontainer Postgres, keep
host: dband ensure the container network matches.
Create and migrate the database:
bin/rails db:create db:migrateFrom the repo root:
bundle installIf you switch Ruby versions in the future, you may want to refresh:
bundle installThis repo uses Yarn 4 with Plug'n'Play. The package.json declares:
"packageManager": "yarn@4.x.x"Enable Corepack and install dependencies:
corepack enable
yarn installThis will create/update:
.pnp.cjs.pnp.loader.mjs.yarn/(PnP cache)yarn.lock
To build the JS bundles into app/assets/builds:
yarn buildThis compiles:
app/javascript/application.jsapp/javascript/cms.jsapp/javascript/document.js
into app/assets/builds, which Rails serves via the asset pipeline.
bin/rails serverVisit:
http://localhost:3000
The JS assets will come from the last yarn build.
Use this when you just need the backend running and don’t need live JS rebuilds.
bin/dev runs both the Rails server and a JS build watcher via foreman:
bin/devThis uses Procfile.dev to start:
web:bin/rails server -p 3000js:yarn build --watch
Use this when actively working on JavaScript; changes will trigger rebuilds.
If foreman is missing, bin/dev will install it automatically with the
currently active Ruby (via asdf).
-
Run Rails console
bin/rails console
-
Run tests
bundle exec rspec -
Rebuild JS assets
yarn build
-
Ruby version mismatch
- Ensure
asdfis initialized in your shell. - Run
asdf installand verify withasdf currentandruby -v.
- Ensure
-
Database connection errors
- Check
config/database.yml(host,username,password). - Ensure PostgreSQL is running.
- Check
-
Missing JS assets (
application.jsnot present in asset pipeline)- Run
yarn installandyarn build. - Then restart
bin/rails serverorbin/dev.
- Run