Skip to content
paradisec-archivePublic

About

nabu is a digital media item management system that provides a catalog of audio and video items, metadata for these items, and information about the workflow status of the items.

Resources

Stars

21 stars

Watchers

9 watching

Forks

Latest commit

 

History

3,256 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nabu Catalog

Setting up your dev environment

Use direnv to add bin to your path

PATH_add bin

Bring up the environment

# Build the base image
docker compose build

# Install the gems
nabu_run bundle

# Bring up all the containers
docker compose up

This brings up the following containers

  • app - the rails app
  • search - OpenSearch instance for search (dev + test), pinned to production's version
  • db - mysql data base (dev + test)
  • s3 - s3 mock

You can then easily run all the standard commands by prefixing with nabu

nabu_run bundle install
nabu_run bundle exec rake db:prepare

Resetting the search data volume after the OpenSearch 2.19 pin

OpenSearch was previously latest (3.x) locally. A data volume written by 3.x can't be opened by 2.19, so reset it once and reindex development data. This briefly breaks search specs in every other checkout, so stop other test runs first.

docker compose rm --stop --force search
docker volume rm nabu_search-data
docker compose up --detach search
nabu_run bin/rake searchkick:reindex:all

Test indices are recreated by the next bin/test run.

Running tests

nabu_run bin/test                          # the whole suite, in parallel
nabu_run bin/test spec/models/item_spec.rb # specific files or examples
nabu_run bin/test --only-failures          # what failed last time

bin/test prepares the test databases before running RSpec, so a fresh checkout or a branch switch needs no manual step.

With no arguments bin/test runs the suite across parallel workers with parallel_tests, each with its own databases, search indices and bucket (e.g. nabu_test_2). It uses 4 workers, so that concurrent runs leave each other room; set PARALLEL_TEST_PROCESSORS to change that, as CI does to use every core. Any argument runs plain RSpec in a single process.

Each linked git worktree gets its own test namespace: its own test databases, search indices and catalogue bucket on the shared containers, named after the worktree (e.g. nabu_test_<worktree>). The main checkout keeps the plain nabu_test names. Set NABU_TEST_NAMESPACE to choose a namespace explicitly, or to an empty string for the plain names.

Checking your work

nabu_run bin/ci

bin/ci runs rubocop, brakeman and bundle-audit, then bin/test if those passed. It reports each step's runtime and exits non-zero if any fails. The steps live in config/ci.rb. GitHub Actions runs the same checks, with linting, security scanning and the tests as separate jobs.

Pruning test namespaces

Namespaces outlive their worktrees. Run bin/test_prune on the host to list the test databases, search indices and catalogue buckets that belong to no current worktree, then bin/test_prune --delete to drop them. The main checkout's names are never touched. A namespace set by hand with NABU_TEST_NAMESPACE counts as orphaned unless it matches a current worktree's name.

Production

The application is designed to be deployed with containers into an AWS account using CDK

To bootstrap a new account

# Setup an AWS account and credentials as per your preferred method and set the environment to use it
AWS_PROFILE=nabu
REGION=ap-southeast-2
ACCOUNT=$(aws sts get-caller-identity | jq -r .Account)
cdk bootstrap aws://$ACCOUNT/$REGION

If ECR complains about access

ACCOUNT=$(AWS_PROFILE=nabu-stage aws sts get-caller-identity | jq -r .Account)
AWS_PROFILE=nabu-stage aws ecr get-login-password --region ap-southeast-2 | docker login --username AWS --password-stdin $ACCOUNT.dkr.ecr.ap-southeast-2.amazonaws.com

Deployment

Use CDK to deploy new code via docker as well as any infrastructure changes

bin/release stage
bin/release prod

If necessary:

bin/aws/ecs_rake app db:migrate
bin/aws/ecs_rake app search:reindex

Importing a production database into your development environment

bin/aws/db_sync dumps the production database to S3, restores it into your local nabu_devel, and resets every user's password to password. See docs/runbooks/db-sync.md for the full design (it can also overwrite staging).

bin/aws/db_sync   # choose target 1) dev
nabu_run bin/rails db:environment:set RAILS_ENV=development
nabu_run bin/rake db:migrate
nabu_run bin/rake searchkick:reindex:all

Language data

Every Language is brought into line with its Source by the Language Refresh, which runs monthly on the first Tuesday and emails a report. It reads ISO 639-3 from SIL, Glottolog from its latest release and AUSTLANG from AIATSIS, regenerates the advisory Equivalents, fills empty Bounding boxes and lists what needs a person.

To run one by hand:

nabu_run bin/rake languages:refresh

OAI-PMH

OLAC available at:

The feeds that OLAC harvests:

Individual item:

RIF-CS available at:

The feed that ANDS harvests:

Test at ANDS:

Feed for a single collection:

To validate our XML output as per OLAC

java -cp xercesImpl.jar:xercesSamples.jar sax.Counter -n -np -v -s -f item.xml

Setup Secrets

aws secretsmanager list-secrets

aws secretsmanager put-secret-value --secret-id ARN --secret-string "{\"site_key\":\"***\", \"secret_key\":\"***\"}"

Upgrades

We should regularly make sure we are running the latest versions of third-party packages

# Ruby gems
nabu_run bundle outdated
nabu_run bundle update

# node modules
nabu_run pnpm up -i

# New rails version
rails new nabu --database=mysql --javascript=esbuild --css=sass --skip-action-cable --skip-kamal

About

nabu is a digital media item management system that provides a catalog of audio and video items, metadata for these items, and information about the workflow status of the items.

Resources

Stars

21 stars

Watchers

9 watching

Forks

Releases

Packages

Used by

Contributors

Languages