Simple Rails API that needs some devop stuff on it.
- Ruby 3.3.6
- Rails 7.1
- PostgreSQL
- Puma
- Install Ruby 3.3.6 (use your version manager of choice, e.g.
rbenv install 3.3.6). - Install the dependencies:
$ bundle install - Ensure PostgreSQL is running and reachable on port 5432.
- Setup development & test DBs:
$ bin/rails db:setup - Fill with some data:
$ bin/rails db:seed
- Ensure the db is running on port 5432.
- Start the app:
$ bin/rails s - Liveness check:
$ curl -v http://localhost:3000/ping; echo - Readiness check (verifies DB connectivity):
$ curl -v http://localhost:3000/status; echo
GET /ping— returns a sample response (liveness).GET /status— returns{ "status": "ok", "database": "connected" }when the app can reach the database (readiness). Returns HTTP 503 otherwise.
- Ensure the db is running on port 5432.
$ bundle exec rspec
$ bundle exec rubocop
Database credentials are set in config/database.yml, but Rails can also take the db connection string from the DATABASE_URL env variable.