This Ruby on Rails 7 api only application can used to quickly start development using JWT authentication token.
- create
config/database.yml
and add following content
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
database: <%= ENV.fetch("DATABASE_NAME") %>
username: <%= ENV.fetch("DATABASE_USERNAME") %>
password: <%= ENV.fetch("DATABASE_PASSWORD") %>
host: <%= ENV.fetch("DATABASE_HOST") %>
port: 5432
development:
<<: *default
test:
<<: *default
- Setup database using
rails db:create db:migrate
- create
.env.development.local
for development - create
.env.test.local
for test
POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_DB=
POSTGRES_HOST=
Note: Since docker postgres image consider POSTGRES_ prefix as environment variable, we are using it.
- RSpec is used for testing. Run
rspec
command to test
- Run
rails s
to start server
- Install docker in machine if not already
- Build image using docker compose
sudo docker compose up --build