You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: documentation/developing-your-hyrax-based-app.md
+76-59
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,8 @@ A Hyrax-based application includes lots of dependencies. We provide a [Docker im
29
29
30
30
You can also try [Running Hyrax-based application in local VM](https://github.com/samvera/hyrax/wiki/Hyrax-Development-Guide#running-hyrax-based-application-in-local-vm) which uses Ubuntu.
31
31
32
+
During development, running only the dependent services in a container environment may be beneficial. This avoids potential headaches concerning file permissions and eases the use of debugging tools. The application generation instructions below use [Lando](https://lando.dev) to achieve this setup.
33
+
32
34
This document contains instructions specific to setting up an app with __Hyrax
33
35
v5.0.0.rc2__. If you are looking for instructions on installing a different
34
36
version, be sure to select the appropriate branch or tag from the drop-down
@@ -44,8 +46,8 @@ Prerequisites are required for both creating a Hyrax\-based app and contributing
44
46
Hyrax requires the following software to work:
45
47
46
48
1.[Solr](http://lucene.apache.org/solr/) version >= 5.x (tested up to 8.11.1, which includes the log4j library update)
47
-
1.[Fedora Commons](http://www.fedora-commons.org/) digital repository version >= 4.5.1 (tested up to 4.7.5)
48
-
1. A SQL RDBMS (MySQL, PostgreSQL), though **note** that SQLite will be used by default if you're looking to get up and running quickly
49
+
1.[Fedora Commons](http://www.fedora-commons.org/) digital repository version >= 4.7.6 (if not using the Valkyrie Postgres adapter)
50
+
1. A SQL RDBMS ([PostgreSQL](https://www.postgresql.org) recommended)
49
51
1.[Redis](http://redis.io/), a key-value store
50
52
1.[ImageMagick](http://www.imagemagick.org/) with JPEG-2000 support
51
53
1.[FITS](#characterization) (tested up to version 1.5.0 -- avoid version 1.1.0)
@@ -55,7 +57,12 @@ Hyrax requires the following software to work:
55
57
**NOTE: The [Hyrax Development Guide](https://github.com/samvera/hyrax/wiki/Hyrax-Development-Guide) has instructions for installing Solr and Fedora in a development environment.**
56
58
57
59
### Characterization
60
+
#### Servlet FITS
61
+
FITS can be run as a web service. This has the benefit of improved performance by avoiding the slow startup time inherent to the local option below.
62
+
63
+
A container image is available for this purpose: [ghcr.io/samvera/fitsservlet](https://ghcr.io/samvera/fitsservlet)
58
64
65
+
#### Local FITS
59
66
FITS can be installed on OSX using Homebrew by running the command: `brew install fits`
60
67
61
68
**OR**
@@ -122,34 +129,87 @@ NOTE: [nodejs](https://nodejs.org/en/) is preinstalled on most Mac computers and
122
129
123
130
NOTE: The steps need to be done in order to create a new Hyrax based app.
124
131
132
+
### Development Prerequisites
133
+
134
+
These instructions assume the use of [Lando](https://lando.dev) and [Docker](https://docker.io) to manage the backend services needed by your Hyrax application. Follow the Lando installation instructions before proceeding, or have alternate providers for the services listed in the generated `.lando.yml`:
135
+
- Solr
136
+
- Postgres
137
+
- Redis
138
+
- FITS servlet
139
+
- Fedora (if not using Postgres)
140
+
141
+
### Generate the application
142
+
125
143
Generate a new Rails application using the template.
126
144
127
-
```
128
-
rails _6.1.7.6_ new my_app -m https://raw.githubusercontent.com/samvera/hyrax/hyrax-v5.0.0.rc2/template.rb
145
+
```shell
146
+
rails _6.1.7.6_ new my_app --database=postgresql -m https://raw.githubusercontent.com/samvera/hyrax/hyrax-v5.0.0.rc2/template.rb
129
147
```
130
148
131
149
Generating a new Rails application using Hyrax's template above takes cares of a number of steps for you, including:
132
150
133
151
* Adding Hyrax (and any of its dependencies) to your application `Gemfile`, to declare that Hyrax is a dependency of your application
134
152
* Running `bundle install`, to install Hyrax and its dependencies
135
153
* Running Hyrax's install generator, to add a number of files that Hyrax requires within your Rails app, including e.g. database migrations
154
+
155
+
### Start Services
156
+
157
+
Start the background services managed by Lando. The
158
+
159
+
```shell
160
+
cd my_app
161
+
lando start
162
+
```
163
+
164
+
### Run Migrations/Seeds
165
+
166
+
This performs the following actions:
167
+
136
168
* Loading all of Hyrax's database migrations into your application's database
137
-
* Loading Hyrax's default workflows into your application's database
138
169
* Create default collection types (e.g. Admin Set, User Collection)
170
+
* Loading Hyrax's default workflows into your application's database
171
+
172
+
```shell
173
+
rails db:migrate
174
+
rails db:seed
175
+
```
139
176
140
-
### Start servers
177
+
**NOTE**: You will want to run these commands the first time this code is deployed to a new environment as well.
141
178
142
-
To test-drive your new Hyrax application in development mode, spin up the servers that Hyrax needs (Solr, Fedora, and Rails):
179
+
This creates the default administrative set -- into which all works will be deposited unless assigned to other administrative sets.
180
+
This command also makes sure that Hyrax's built-in workflows are loaded for your application and available for the default administrative set.
181
+
182
+
### Generate a work type
183
+
184
+
Using Hyrax requires generating at least one type of repository object, or "work type." Hyrax allows you to generate the work types required in your application by using a Rails generator-based tool. You may generate one or more of these work types.
185
+
186
+
Pass a (CamelCased) model name to Hyrax's work generator to get started, e.g.:
143
187
144
188
```
145
-
bin/rails hydra:server
189
+
rails generate hyrax:work_resource MovingImage
190
+
```
191
+
192
+
If your applications requires your work type to be namespaced, namespaces can be included by adding a slash to the model name which creates a new class called `MovingImage` within the `My` namespace:
193
+
194
+
```shell
195
+
rails generate hyrax:work_resource My/MovingImage
196
+
```
197
+
198
+
You may wish to [customize your work type](https://github.com/samvera/hyrax/wiki/Customizing-your-work-types) now that it's been generated.
199
+
200
+
### Start Hyrax web server
201
+
202
+
Test-drive your new Hyrax application in development mode:
203
+
204
+
```shell
205
+
rails s
146
206
```
147
207
148
208
And now you should be able to browse to [localhost:3000](http://localhost:3000/) and see the application.
149
209
150
210
Notes:
151
211
* This web server is purely for development purposes. You will want to use a more fully featured [web server](https://github.com/samvera/hyrax/wiki/Hyrax-Management-Guide#web-server) for production-like environments.
152
-
*You have the option to start each of these services individually. More information on [solr_wrapper](https://github.com/cbeer/solr_wrapper) and [fcrepo_wrapper](https://github.com/cbeer/fcrepo_wrapper) will help you set this up. Start rails with `rails s`.
212
+
*For a fresh start, the data persisted in Lando can be wiped using `lando destroy`.
153
213
154
214
### Start background workers
155
215
@@ -163,14 +223,10 @@ Many of the services performed by Hyrax are resource intensive, and therefore ar
163
223
164
224
Hyrax implements these jobs using the Rails [ActiveJob](http://edgeguides.rubyonrails.org/active_job_basics.html) framework, allowing you to choose the message queue system of your choice.
165
225
166
-
For initial development, it is recommended that you change the default ActiveJob adapter from `:async` to `:inline`. This adapter will execute jobs immediately (in the foreground) as they are received. This can be accomplished by adding the following to your `config/environments/development.rb`
226
+
For initial development, it is recommended that you change the default ActiveJob adapter from `:async` to `:inline`. This adapter will execute jobs immediately (in the foreground) as they are received. This can be accomplished by modifying the `.env` file:
167
227
168
-
```
169
-
class Application < Rails::Application
170
-
# ...
171
-
config.active_job.queue_adapter = :inline
172
-
# ...
173
-
end
228
+
```dotenv
229
+
HYRAX_ACTIVE_JOB_QUEUE=inline
174
230
```
175
231
176
232
For testing, it is recommended that you use the [built-in `:test` adapter](http://api.rubyonrails.org/classes/ActiveJob/QueueAdapters/TestAdapter.html) which stores enqueued and performed jobs, running only those configured to run during test setup. To do this, add the following to `config/environments/test.rb`:
@@ -185,54 +241,15 @@ end
185
241
186
242
**For production applications** you will want to use a more robust message queue system such as [Sidekiq](http://sidekiq.org/). The Hyrax Development Guide has a detailed walkthrough of [installing and configuring Sidekiq](https://github.com/samvera/hyrax/wiki/Using-Sidekiq-with-Hyrax).
187
243
188
-
### Create default administrative set
189
-
190
-
**After** Fedora and Solr are running, create the default administrative set -- into which all works will be deposited unless assigned to other administrative sets -- by running the following command:
191
-
192
-
```
193
-
rails hyrax:default_admin_set:create
194
-
```
195
-
196
-
This command also makes sure that Hyrax's built-in workflows are loaded for your application and available for the default administrative set.
197
-
198
-
**NOTE**: You will want to run this command the first time this code is deployed to a new environment as well.
199
-
200
-
### Generate a work type
201
-
202
-
Using Hyrax requires generating at least one type of repository object, or "work type." Hyrax allows you to generate the work types required in your application by using a Rails generator-based tool. You may generate one or more of these work types.
203
-
204
-
Pass a (CamelCased) model name to Hyrax's work generator to get started, e.g.:
205
-
206
-
```
207
-
rails generate hyrax:work Work
208
-
```
209
-
210
-
or
211
-
212
-
```
213
-
rails generate hyrax:work MovingImage
214
-
```
215
-
216
-
If your applications requires your work type to be namespaced, namespaces can be included by adding a slash to the model name which creates a new class called `MovingImage` within the `My` namespace:
217
-
218
-
```
219
-
rails generate hyrax:work My/MovingImage
220
-
```
221
-
222
-
You may wish to [customize your work type](https://github.com/samvera/hyrax/wiki/Customizing-your-work-types) now that it's been generated.
223
-
224
-
### Enable notifications
225
-
226
-
Hyrax 2+ uses a WebSocket-based user notifications system, which requires Redis. To enable user notifications, make sure that you have configured ActionCable to use Redis as the adapter in your application's `config/cable.yml`. E.g., for the `development` Rails environment:
244
+
### Create an Admin User
227
245
246
+
To access all of Hyrax's features you must be signed in as a user in the `admin` role. The default role management system uses the `config/role_map.yml` file to assign users to roles. For example:
Note that the Hyrax Management Guide contains additional information on [how to configure ActionCable in production environments](https://github.com/samvera/hyrax/wiki/Hyrax-Management-Guide#notifications).
235
-
236
253
## Managing a Hyrax-based app
237
254
238
255
The [Hyrax Management Guide](https://github.com/samvera/hyrax/wiki/Hyrax-Management-Guide) provides tips for how to manage, customize, and enhance your Hyrax application, including guidance specific to:
0 commit comments