Building from Scratch - RepoCamp/ohsu2018 GitHub Wiki

This guide walks you through the steps to set up a template-generated instance of Hyrax which can be used with the other tutorials in this Wiki. We have followed the main outline of the instructions in the Hyrax README, and we have added the steps to make using a Vagrant-based virtual machine easier.

Goals:

  • Start a vagrant-based virtual machine
  • Set up a Hyrax-based Rails application
  • Start Solr, Fedora, and Web servers
  • Be able to log into a local Hyrax instance and submit a work

Prerequisites

  • Recent version of VirtualBox installed
  • Recent version of Vagrant installed
  • A Vagrantfile which loads a VM pre-loaded with the Hyrax prerequisites

Steps

  1. Start your VM using vagrant up and connect with vagrant ssh.
  2. Navigate to your working directory - /vagrant will give you a VM-mounted instance of the directory from which you started vagrant
    cd /vagrant
    
  3. Generate a Hyrax application using the basic application template
    rails _5.1.6_ new hyrax-demo -m https://raw.githubusercontent.com/samvera/hyrax/v2.1.0.beta2/template.rb --no-spring
    

    NOTE: using the template file above to set up your application is equivalent to running the following individual commands

    1. Run rails _5.1.6_ new hyrax-demo --no-spring
    2. cd hyrax-demo
    3. Add gem 'hyrax', '2.1.0.beta2' to your Gemfile
    4. bundle install
    5. rails generate hyrax:install -f
    6. rails db:migrate
  4. Change directory to the root of the newly generated application
    cd hyrax-demo
    
  5. For the tutorials, set background jobs to run inline by editing config/application.rb around line 11
    # after the line
    #   class Application < Rails::Application
    
        config.active_job.queue_adapter = :inline
    
  6. Point your solr config at the local (already downloaded) Solr instance in /var/tmp by adding these lines to the top of hyrax-demo/.solr_wrapper:
    version: 6.6.0
    download_dir: /var/tmp
    
  7. Point your fedora config at the local (already downloaded) Fedora instance in /var/tmp by adding these lines to the end of hyrax-demo/.fcrepo_wrapper:
    version: 4.7.5
    download_dir: /var/tmp
    
  8. Start Solr, Fedora, and Web servers in a new terminal window. You'll want to leave these running in a separate window while you use your first terminal session for command-line exercises in the tutorials.
    # after you open a new terminal window
    vagrant ssh
    
    then, in the new terminal session after you ssh
    cd /vagrant/hyrax-demo
    rails hydra:server
    

    NOTE: alternatively you can start services individually and send them to the background:

    cd /vagrant/hyrax-demo
    solr_wrapper &
    fcrepo_wrapper &
    rails server &
    
    Leave this session running for the rest of the tutorial. Hold down Ctrl-C to stop the servers, and type exit when you're done with the terminal window. You can now use your primary terminal window for the remaining exercises.
  9. Generate the default admin set:
    rails hyrax:default_admin_set:create
    
  10. Create a work type to be used in future tutorials. To generate a new work type, we follow the instructions in the Hyrax README. In this case, our work type will be Work.
    rails generate hyrax:work Work
    
    Restart Rails after generating a new work type, if Rails was running already.
  11. Open a browser window and go to http://localhost:3000. You should be able to create an account and log in. Once you have logged in, go to http://localhost:3000/concern/works/new. You should be able to submit a new Work object.

Sample Code

To see the sample application at this stage, go to https://github.com/RepoCamp/ohsu2018/tree/walkthrough