Repository navigation
DEPRECATED: Developing Ursus in Docker
Warning
Deprecated documentation
This page is retained for historical reference and may no longer describe the current Ursus application or development environment.
For current documentation, start with Solr in Ursus.
$ git clone git@github.com:UCLALibrary/ursus.git
$ cd ursus
$ docker-compose run web bundle exec rails db:setup
$ docker-compose up
Ursus should now be running on port 3003.
The data you're viewing is coming from a solr instance, preloaded with data from Californica-test, and should not need to be changed in most cases, since ursus is a discovery interface only. You can see the solr console on port 8983.
- Connect to a shell inside the container with
docker-compose run web bash - Run
bundle exec rspec spec
The primary docker-compose.yml uses a clone of ursus-test's (??? dev? stage? prod?) solr index. This enables you to run a local instance of ursus while using our test servers to obtain IIIF manifests and image tiles.
Unfortunately the solr index has to be manually obtained from our backups and checked in to the UCLALibrary/docker-solr-ursus repo, which will trigger a build of uclalibrary/solr-ursus on dockerhub.
Sometime you will need to develop in an environment where Ursus and Californica are sharing the same Solr data.
In Ursus the standard developer environment comes pre-populated with data from Californica-test.
In order to use other data, you will need to run our management app Californica alongside Ursus. The file docker-compose-with-californica.yml is set up to allow this.
-
Get your Californica environment running Follow the Californica instructions to get a local instance of Californica running on
port 3000 -
Get your Ursus environment running
-
Spin up your environment and start the app:
docker-compose -f docker-compose-with-californica.yml up
-
Run the database migration
docker-compose -f docker-compose-with-californica.yml run web bundle exec rake db:setup
Note: If you get a database error make sure that you are running californica as outlined above (1. Get your Californica environment running)
Mysql2::Error::ConnectionError Unknown MySQL server host 'db' (-2) -
-
You will have to explicitly specify the alternate
docker-composefile every time you run adocker-composecommand
For example:- Open a shell inside a container
docker-compose -f docker-compose-with-californica.yml run web bash - Run the test suite
docker-compose -f docker-compose-with-californica.yml run web bundle exec rspec spec
- Open a shell inside a container
- add a
byebugcall in the code you want to debug - restart the web container by running
docker-compose restart web - run docker ps and get the of the ursus/web container.
- run
docker attach <ID>and press enter. You'll be able to access the byebug prompt.
- add a
byebugcall in the code you want to debug - run your test suite in the way you normally do
It is possible to run rails natively against backing services running in docker. Personally, I run the rails server in docker but like to run tests and rake commands natively. This has the side benefit of maintaining a copy of Ursus' various dependency libraries in a place where a text editor can find them (they're not very good at digging through docker containers).
I haven't worked out consistent instructions for doing this yet, however. Here's a rough outline:
- Install the proper version of ruby with rvm, rbenv, or similar.
- Change
config/solr.ymlandconfig/blacklight.ymlto point tohttp://localhost:8983/solr/calursusby default. - Point
config/database.ymltohttp://127.0.0.1:3306by default. It's important to not uselocalhosthere, because that would make the mysql client try to connect via a socket, which doesn't work with docker. - Run
bundle install