Invoice REST API
- Docker desktop
- Ruby: 3.2.2
- Rails: 7.0.6
- MYSQL: 8 (Optional)
- Database MYSQL
- Sign in and sign up via email.
- Docker containers for Ruby on Rails development in Visual Studio Code. (References).
- Rspec. (Refrences)
- Solargraph. (References)
- Rubocop. (References)
- Swagger (Need Improvement). (References)
git clone https://github.com/zaychoer/invoice-api.git
cd invoices-api
cp env-example .env
docker compose up -d
docker compose run --rm web bundle install
docker compose run --rm web bin/rails db:create
docker compose run --rm web bin/rails db:migrate
rake secret -> generate key
EDITOR="code --wait" rails credentials:edit -> to open credential.yaml.enc file
Place your generate key inside credentials.yaml.enc like this
devise_jwt_secret_key: generate key
For check status run
docker compose logs
If you set up Docker Compose to start Rails at startup, it is convenient to compare the commands to Rails from outside the container and the commands to Rails from inside the container, as shown in the table below.
Commands to Rails from outside the container | Commands to Rails from inside the container |
---|---|
docker compose run --rm web bundle install | bundle install |
docker compose run --rm web bin/rails db:migrate | bin/rails db:migrate |
docker compose exec web bin/rails c | bin/rails c |
docker compose exec web bundle exec rspec | bundle exec rspec |
docker compose run -e EDITOR=vi web bin/rails credentials:edit | bin/rails credentials:edit |
git clone https://github.com/zaychoer/invoice-api.git
cd invoices-api
cp env-example .env
bundle install
rails db:create
rails db:migrate
rake secret -> generate key
EDITOR="code --wait" rails credentials:edit -> to open credential.yaml.enc file
Place your generate key inside credentials.yaml.enc like this
devise_jwt_secret_key: generate key
- Change
DB_USER=your-own-user
- Change
DB_HOST=your-own-db-host
- Change
DB_PASSWORD=your-own-db-password
Run additional container:
docker compose up -d db adminer
- Swagger: http://localhost:3000/api-docs
- Adminer (client for DB): http://localhost:9090/
Auth for Adminer
System : MySQL
Server : db
User : root
Password : password
bundle exec rspec
docker compose exec web bundle exec rspec
- Invoice Api Postman Collection (Link)