Skip to content

Instantly share code, notes, and snippets.

@escowles
Last active February 24, 2023 15:43
Show Gist options
  • Save escowles/f59fd919ca41c5adb6cee37e14c8db5a to your computer and use it in GitHub Desktop.
Save escowles/f59fd919ca41c5adb6cee37e14c8db5a to your computer and use it in GitHub Desktop.
Fedora/Solr Quick Start

Quick Start

  1. Download Fedora jar file from GitHub: https://github.com/fcrepo4/fcrepo4/releases, or download a known release with curl:

    $ curl -L https://github.com/fcrepo4/fcrepo4/releases/download/fcrepo-4.7.1/fcrepo-webapp-4.7.1-jetty-console.jar > fcrepo-webapp-4.7.1-jetty-console.jar
  2. Run Fedora:

    $ nohup java -jar fcrepo-webapp-4.7.1-jetty-console.jar --headless > fcrepo.log 2>&1 &

Fedora is at http://localhost:8080/rest

  1. Download Solr from Apache: http://lucene.apache.org/solr/mirrors-solr-latest-redir.html, or download a known release from a mirror:

    $ curl http://mirrors.ibiblio.org/apache/lucene/solr/6.4.1/solr-6.4.1.tgz > solr-6.4.1.tgz
  2. Unpack and start Solr, then create a core using your application's Solr config directory:

    $ tar xvfz solr-6.4.1.tgz
    $ cd solr-6.4.1
    $ bin/solr start
    $ bin/solr create_core -c demo -d /path/to/solr/config

Solr is at http://localhost:8983/solr/demo/select

Test and Development

Running your Hydra application in development mode

You should be able to run any Hydra application with the hydra:server Rake task:

$ rake hydra:server

If you want to run each piece separately, you can run these three commands in separate windows:

$ solr_wrapper -p 8983 -i tmp/solr-development -d solr/config -n hydra-development
$ fcrepo_wrapper -p 8984 --no-jms -d tmp/fcrepo4-development-data
$ rails server

Running your tests

You should setup a ci Rake task in your application's Rakefile, such as:

require 'solr_wrapper'
require 'fcrepo_wrapper'
require File.expand_path('../config/application', __FILE__)

task :ci do
  with_server 'test' do
    Rake::Task['spec'].invoke
  end
end

Then you can run your tests with:

$ rake ci

If you want to run each piece separately, you can run these three commands in separate windows:

$ solr_wrapper -p 8985 -i tmp/solr-test -d solr/config -n hydra-test
$ fcrepo_wrapper -p 8986 --no-jms -d tmp/fcrepo4-test-data
$ rspec

Tomcat

To allow for greater customization, it is recommended that you setup Apache Tomcat and deploy the Fedora war file, instead of running the one-click jar file. This allows you to customize the binary and metadata storage options, and generally provides much more flexibility.

To setup Tomcat and deploy the Fedora web application:

  1. Download the Fedora war file from https://github.com/fcrepo4/fcrepo4/releases

  2. Download Tomcat from http://tomcat.apache.org/download-80.cgi

  3. Unpack the Tomcat distribution

    $ tar xvfz apache-tomcat-8.5.11.tar.gz
  4. Create a Fedora configuration file by customizing one of the fcrepo-config configurations, and place it in Tomcat's conf directory. For example, if you're using PostgreSQL, your config might look like apache-tomcat-8.5.11/conf/fcrepo4.json:

    {
      "name": "repo",
      "jndiName": "",
      "workspaces": {
        "predefined": [
          "default"
        ],
        "default": "default",
        "allowCreation": true
      },
      "storage": {
        "persistence": {
          "type": "db",
          "connectionUrl": "jdbc:postgresql://${fcrepo.postgresql.host:localhost}:${fcrepo.postgresql.port:5432}/fcrepo",
          "driver": "org.postgresql.Driver",
          "username": "${fcrepo.postgresql.username}",
          "password": "${fcrepo.postgresql.password}"
        },
        "binaryStorage": {
          "type": "file",
          "directory": "${fcrepo.binary.directory:target/binaries}",
          "minimumBinarySizeInBytes": 4096
        }
      },
      "security": {
        "anonymous": {
          "roles": [
            "readonly",
            "readwrite",
            "admin"
          ],
          "useOnFailedLogin": false
        },
        "providers": [
          {
            "classname": "org.fcrepo.auth.common.BypassSecurityServletAuthenticationProvider"
          }
        ]
      },
      "node-types": [
        "fedora-node-types.cnd"
      ]
    }
  5. Create a script called apache-tomcat-8.5.11/bin/setenv.sh to hold your Java configuration and private configuration paramters:

    JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"
    JAVA_OPTS="$JAVA_OPTS -Xmx8g"
    JAVA_OPTS="$JAVA_OPTS -XX:+UseG1GC"
    JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC"
    JAVA_OPTS="$JAVA_OPTS -Dfcrepo.modeshape.configuration=file:///path/to/apache-tomcat-8.5.11/conf/fcrepo4.json"
    JAVA_OPTS="$JAVA_OPTS -Dfcrepo.postgresql.username=fcrepo
    JAVA_OPTS="$JAVA_OPTS -Dfcrepo.postgresql.password=XXXXXXXX
    JAVA_OPTS="$JAVA_OPTS -Dfcrepo.binary.directory=/path/to/fcrepo.binary.directory
  6. Copy the Fedora war file into Tomcat's webapps directory

    $ cp fcrepo-webapp-4.7.1.war apache-tomcat-8.5.11/webapps/
  7. Start Tomcat

    $ cd apache-tomcat-8.5.11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment