Full documentation can be found here: https://sardjv.github.io/murfin_method
To get started, you need a .env
file with secrets. If you use bash, you can generate one with the command sh ./script/generate_env_file.sh
. If not, there is an .env.example
file included in the repo that you can use, just remove the .example
from the filename. Make sure to change all secrets marked with YOU_MUST_CHANGE_THIS_PASSWORD before running in production!
You need to set AUTH_METHOD to either form or ldap or oauth2 in the .env file.
You need to add AUTH0_CLIENT_ID and AUTH0_CLIENT_SECRET to the .env file in the Auth0 section.
In the .env file set respective LDAP configuration:
AUTH_METHOD must contain 'ldap' Set all required LDAP_AUTH_ values depending on your LDAP server settings. Examples can be found in .env.example file. After successful authentication on LDAP server side, Murfin+ user is matched with LDAP_AUTH_BIND_KEY and LDAP_AUTH_BIND_KEY pair, e.g. samaccountname => shithjohn. If user can not be found than it's created using pulled email and name details.
No extra settings required.
If you have Docker on your machine:
cp docker-compose.override.yml.sample docker-compose.override.yml
docker-compose build
docker-compose up
It can then be accessed at http://localhost:3000/
Stop containers but do not remove them:
docker-compose stop
Stop containers and remove them:
docker-compose down --remove-orphans
Remove all stopped containers, networks not used by at least one container, dangling images and dangling build cache
docker system prune
You can view keys in the Redis cache from the console with:
Redis.new(url: "redis://redis:#{ENV['REDIS_PORT']}/0", password: ENV['REDIS_PASSWORD'], namespace: ENV['REDIS_CACHE_NAMESPACE']).keys('*')
or
Rails.cache.redis.keys('*')
If you can run Docker, that is the quickest way to get started. If Docker install is not possible, the Dockerfile, docker-compose.yml and Gemfile files included in the repository can be used as a guide for dependencies.
Core dependencies:
- Ruby https://github.com/ruby/ruby
- Rails https://github.com/rails/rails
- Redis https://redis.io/
- Sidekiq https://github.com/mperham/sidekiq
- MySQL
- Multiple supporting gems as listed in the Gemfile, Bundler (included in Ruby) should take care of installing these.
The auto-generated API documentation can be viewed at http://localhost:3000/api_docs.
The Swagger docs are generated from the RSpec tests in spec/api
To rebuild the swagger docs:
docker-compose run --rm app bundle exec rails rswag
Note: --rm option removes container after task ended.
To run Rubocop, and listen for file changes:
docker-compose run app bundle exec guard
Just press enter to run the whole test suite straight away.
To view and interact with a visible Chrome browser in feature tests, uncomment this line in rails_helper.rb
:
c.javascript_driver = :chrome_visible
This exposes a VNC server on port 5900
. You can access it on MacOS with:
open vnc://0.0.0.0:5900
The password is 'secret'. Run a feature spec with that window open and you should see the test running.
Note: feature specs should be run from app shell, so connect first:
docker exec -it murfin_method_app_1 sh
After running the test suite, open the coverage/index.html file in a web browser to check what code is covered by the tests.
open coverage/index.html
To access a 'binding.pry' debugging point, run with:
docker-compose run --service-ports app
To annotate rails models with schema run
docker-compose run --rm app bundle exec annotate --models
To access the MySQL database console:
docker-compose exec db bash
mysql -u root -p
(enter root password)
show databases;
use murfin_method_development;
SELECT * FROM users;
To print a report of time, memory and database calls:
require 'performance'
Performance.test { object.method }
On first run new file is created:
script/first_run_complete.tmp
In some cases deleting it may help with resolving your running issues.