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
- Start your VM using
vagrant upand connect withvagrant ssh. - Navigate to your working directory -
/vagrantwill give you a VM-mounted instance of the directory from which you started vagrantcd /vagrant - 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-springNOTE: using the template file above to set up your application is equivalent to running the following individual commands
- Run
rails _5.1.6_ new hyrax-demo --no-spring cd hyrax-demo- Add
gem 'hyrax', '2.1.0.beta2'to your Gemfile bundle installrails generate hyrax:install -frails db:migrate
- Run
- Change directory to the root of the newly generated application
cd hyrax-demo - For the tutorials, set background jobs to run inline by editing
config/application.rbaround line 11# after the line # class Application < Rails::Application config.active_job.queue_adapter = :inline - Point your solr config at the local (already downloaded) Solr instance in
/var/tmpby adding these lines to the top ofhyrax-demo/.solr_wrapper:version: 6.6.0 download_dir: /var/tmp - Point your fedora config at the local (already downloaded) Fedora instance in
/var/tmpby adding these lines to the end ofhyrax-demo/.fcrepo_wrapper:version: 4.7.5 download_dir: /var/tmp - 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.
then, in the new terminal session after you ssh# after you open a new terminal window vagrant sshcd /vagrant/hyrax-demo rails hydra:server
Leave this session running for the rest of the tutorial. Hold down Ctrl-C to stop the servers, and typeNOTE: alternatively you can start services individually and send them to the background:
cd /vagrant/hyrax-demo solr_wrapper & fcrepo_wrapper & rails server &exitwhen you're done with the terminal window. You can now use your primary terminal window for the remaining exercises. - Generate the default admin set:
rails hyrax:default_admin_set:create - 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.
Restart Rails after generating a new work type, if Rails was running already.rails generate hyrax:work Work - 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 tohttp://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