Skip to content
No description, website, or topics provided.
Shell Dockerfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


HIRMEOS Metrics Docker

This is a docker-compose setup and databases to run all HIRMEOS Work Package 6 services. It assumes the services listed below have been set up in the current directory.

The following env files will need to be set for the containers


After this, docker-compose can be run with

$ docker-compose up

Setup - more detailed

The following is written as a set of steps

Set up values in the databases

Since the different databases are all set up and populated in the postgres_db service, it can be easier to set up certain values before starting the service. Particularly the metrics-api database.

In the db directory, there are subdirectories for each database. Each contain SQL files for the database schema, as well as values to pre-populate the different tables with.

For the metrics-api (db/sql/hirmeos_metrics_api/), it is worth adding to the following files:

  • 50-sources.sql
  • 60-namespaces.sql
  • 70-uploaders.sql
  • 80-namespace_uploaders.sql
  • 90-measures.sql

Use the values already in these files as a guide.

Set up token authentication

First, create the .env files specified above.

Then run docker-compose:

$ docker-compose up

Note: Please see the `Notes on Services` section below if the database does not seem to be set up properly.

Use the instructions specified in the tokens project ( to create an account in the tokens api. Use smae the email and password used in the .env files mentioned as and very_secure_tokens_password in the example files.

Send data to the translator

For any given book, please send as many identifiers as possible. ISBNs are required when using the crossref_uri_import tool, and URLs are needed by the google analytics driver.

The code below shows an example of sending ISBN, doi and URL data for a book. Note the call to the tokens api.

import json
import requests

tokens_url = "http://localhost:8001/tokens"
translator_url = "http://localhost:8002/works"

credentials = {
    'email': '',
    'password': 'very_secure_tokens_password'

# First retrieve token before making requests tot he translator
response =, json=credentials)
token = json.loads(response.content)['data'][0]['token']

header = {"Authorization": "Bearer " + token}

data = {  # Book data to send to the translator
    'title': u'Animal (De)liberation',
    'type': 'monograph',
    'uri': [
        {'URI': 'urn:isbn:978-1-909188-84-6', 'canonical': False},
        {'URI': 'urn:isbn:978-1-909188-83-9', 'canonical': False},
        {'URI': 'urn:isbn:978-1-909188-85-3', 'canonical': False},
        {'URI': 'urn:isbn:978-1-909188-87-7', 'canonical': False},
        {'URI': 'urn:isbn:978-1-909188-86-0', 'canonical': False},
        {'URI': ''},
        {'URI': 'info:doi:10.5334/bay', 'canonical': True}
}, json=data, headers=header)

Services are ready to be used

You can now run the crossref_uri_import tool, as well as the google analytics driver.

Notes on Services:


This has been adapted from the hirmeos-metrics-api project (listed below). Where necessary, this container will host all databases used by the different wp6 services.

The first time this container is started it should create the databases specified in db.env (variable POSTGRES_MULTIPLE_DATABASES), and populate these with the content in the sql folder.

If the tables are not created, you may need run this manually using docker exec

$ docker exec -it postgres_db bash
$ cd docker-entrypoint-initdb.d/
$ ./
$ ./
$ exit

The following WP6 services are also included so far in the docker-compose config file:


The database for this is included in the db/ directory

Impotant: Please follow the instructions listed at to register an email and password with the token api, since many of the services require this to be set up.


The database for this is included in the db/ directory


This also includes metrics_broker_web


  • Not implemented yet; still needs to be set up to run as a cron-job


The database for this is included in the db/ directory


You can’t perform that action at this time.