Setting up a Dev VM for Hyrax - UW-Libraries/druw GitHub Wiki
This is a collection of notes for how to set up a dev VM for Hyrax that allows you contribute to the DRUW git repo. These instructions refer to the instructions on the vagrant-ansible-sufia repo's README but contains things specific for dev instances.
-
Fork the DRUW repo. This is where you will do your developing and will use pull requests as described in the Git Workflow Notes
-
Clone the vagrant-ansible-sufia repo on your host machine.
-
In your copy of that repo,
cp vars.yml.template vars.yml -
Start your vagrant box
vagrant up --provider virtualbox -
Ssh into the box once it's up
vagrant ssh -
Copy your bitbucket private key into your
.sshdirectory. Rename it toid_rsaif necessary and make sure the permissions are 600:chmod 600 ~/.ssh/id_rsa -
Change to the vagrant directory and run the ansible playbook:
cd /vagrant ansible-playbook -i inventory playbook.ymlThis installs a vanilla hyrax app in
~/hyrax/. You'll NEVER actually use that app but it had to be created so you could do the next steps. -
Clone your fork of the DRUW repo from step 1 into your home directory. Make sure it gets placed anywhere EXCEPT for the hyrax directory.
-
Copy all the yml templates to actual yml files:
cd ~/[DRUW_REPO]/config for f in `ls *.yml.template |rev | cut -d '.' --complement -f 1 |rev`; do cp $f{.template,}; doneReplace [DRUW_HOME] with the actual directory you cloned DRUW into.
-
Copy the devise.rb template into the an actual rb file (code below assumes you're in the [DRUW_HOME]/config directory):
cp initializers/devise.rb.template initializers/devise.rb -
Change to the DRUW directory
cd ~/[DRUW_HOME] -
Run
bundle install(doesn't appear to need sudo anymore) -
Start solr
bundle exec solr_wrapper -d solr/config/ --collection_name hydra-development & -
Start fcrepo
bundle exec fcrepo_wrapper -p 8984 & -
Generate the Hydra roles:
rails generate roles -
Migrate your database
rails db:migrate RAILS_ENV=development -
Create the default admin set
rails hyrax:default_admin_set:create -
Create the generic worktype GenericWork.
rails generate hyrax:work GenericWorkThis apparently only does one thing: insert the file
config/initializers/hyrax.rb, but it makes Hyrax a lot happier. -
Finally, start the rails server:
rails server -p 3000 -b 0.0.0.0 -
Check http://localhost:3001 to see if everything is kosher. Initial rendering can take a bit.
-
Create a user as before.
The first administrator you create can only created via the command line as follows:
-
Open the rails console
rails c -
The following code creates the Admin role and adds your user to it
admin = Role.create(name: "admin") u = User.find_by_user_key( "[email protected]" ) admin.users << u admin.save -
Confirm that the user was made an admin
u.admin?The above code should return a
truevalue.
To add other users an administrator, it's pretty straightforward.
-
Make sure the user you want to make an admin has already created a regular user account.
-
Login as an administrator
-
Go to
http://[hyrax_url:port]/roles -
Select a role and add users to that role.
-
From your terminal where you run vagrant, run
vagrant ssh-config. Note the file location forIdentityFile. This is your vagrant private key. -
Run
puttygen.exe -
Loadthe private key from theIdentityFileLocation. You'll get a message saying it has been convert to putty format. -
Save private key. You can enter a passphrase if you want. Just choose a name likevagrant-putty-private.ppk. -
In WinSCP, set up your profile:
Protocol: SFTP Host name: 127.0.0.1 Port number: 2222 User name: vagrant -
Open the Advanced Menu in the profile setup in WinSCP and choose the SSH -> Authentication tab. Under Authentication parameters:
-
Check Allow agent forwarding
-
In the Private key file include the path to the putty private key you created earlier.
-
-
Save your profile and you should be able to connect to your VM via WinSCP.