Frontend for the COP, built with Ruby on Rails and Blacklight plus a Solr backend.
The application provides the web interface for searching and browsing COP editions. Search and record data are retrieved from a Solr backend.
The application consists primarily of:
- Ruby on Rails 5.1.7 — web application and frontend
- Blacklight 6.20.0 — search interface and Solr integration
- Solr — backend search/index containing COP edition data
- Puma 4.3.12 — development web server
- SQLite — local Rails development database
Everything (Ruby 2.6.5, Bundler 1.17.2, all gems and native build deps) is installed in the image; you only need Docker with Compose.
docker compose --file docker/compose.yaml up --buildOpen http://localhost:3000. The source is bind-mounted, so edits are picked up without a restart (allow a few seconds). Migrations run automatically on start.
- Solr: by default the app uses the KB-internal
cop-devel-01.kb.dkSolr, so you must be on the KB network/VPN. Point elsewhere withSOLR_URL=http://host:port/solr/core docker compose --file docker/compose.yaml up. - Port taken?
COP_PORT=3001 docker compose --file docker/compose.yaml uppublishes on another host port. - After changing
Gemfile/Gemfile.lock:docker compose --file docker/compose.yaml build. - Rails console:
docker compose --file docker/compose.yaml exec web bin/rails console. - byebug: run
docker compose --file docker/compose.yaml up -d, thendocker compose --file docker/compose.yaml attach web(detach withCtrl-p Ctrl-q). - Reset the dev database:
docker compose --file docker/compose.yaml run --rm web bin/rails db:reset. - Shorter commands:
export COMPOSE_FILE=docker/compose.yamlin the repo root lets you drop--file docker/compose.yaml. - The image is
linux/amd64only (therubyracer's libv8 has no ARM build); on ARM machines it runs under emulation.
The manual setup below is the alternative to Docker.
The repository is an older Rails application and requires specific versions of Ruby and Bundler.
| Dependency | Version |
|---|---|
| Ruby | 2.6.5 |
| Bundler | 1.17.2 |
| Rails | 5.1.7 |
| Blacklight | 6.20.0 |
| Puma | 4.3.12 |
The exact Ruby and Bundler versions are also reflected in Gemfile.lock.
You will need:
- Git
- Ruby 2.6.5
- Bundler 1.17.2
- Node/npm are not required to run the Rails application
The easiest way to manage Ruby versions is rbenv.
git clone https://github.com/kb-dk/COP-frontend.git
cd COP-frontendOn Ubuntu:
sudo apt update
sudo apt install rbenv ruby-buildIf the Ubuntu ruby-build package is too old to provide Ruby 2.6.5, install/update ruby-build from the upstream project.
After installing rbenv, make sure it is initialized in your shell.
Check that it works:
rbenv --versionFrom the repository:
rbenv install 2.6.5You might run into problems here if you're on a newer version of Ubuntu (26.04 or above). To remove the errors, do this intall instead:
export CFLAGS="-std=gnu11 -Wno-error=incompatible-pointer-types"
export RUBY_CONFIGURE_OPTS="--disable-jit-support"
rbenv install 2.6.5If it is already installed, this step can be skipped.
Set Ruby 2.6.5 as the Ruby version for this project only:
rbenv local 2.6.5If you're using a newer Ubuntu version (26.04 or newer), you may need to add rbenv to your PATH manually in ~/.bashrc:
export PATH="$HOME/.rbenv/bin:$PATH"After adding it, reload your shell configuration:
source ~/.bashrcThis creates a .ruby-version file.
Verify:
ruby --versionYou should see something similar to:
ruby 2.6.5p114
Using rbenv local is preferable to changing your global Ruby version, since other projects may require newer Ruby versions.
The project uses Bundler 1.17.2:
gem install bundler -v 1.17.2Verify:
bundle _1.17.2_ --versionExpected:
Bundler version 1.17.2
From the repository root:
bundle _1.17.2_ installAgain, on newer Ubuntus (26.04 and above), you might run into problems here. If you do, you should run the install command with the following flags:
bundle config build.sqlite3 --with-cflags="-Wno-error=incompatible-pointer-types -Wno-error=int-conversion -std=gnu99"
bundle _1.17.2_ installThis installs the dependencies specified by the Gemfile and Gemfile.lock.
The first time the application is started, Rails may report:
ActiveRecord::PendingMigrationError
If so, run:
bundle _1.17.2_ exec rails db:migrateYou normally only need to do this once, unless new migrations are added.
Start the Rails development server:
bundle _1.17.2_ exec rails serverYou should see something similar to:
=> Booting Puma
=> Rails 5.1.7 application starting in development
* Version 4.3.12 (ruby 2.6.5-p114)
* Listening on tcp://127.0.0.1:3000
Open:
http://localhost:3000