Dockerize D2RQ platform

@Alex Tucker Alex Tucker authored on 22 Mar 2017
Dockerfile Rework to download platform from upstream and clean up docker image. Add license. 7 years ago
README.md Rework to download platform from upstream and clean up docker image. Add license. 7 years ago
README.md

D2RQ

Accessing Relational Databases as Virtual RDF Graphs

From http://d2rq.org:

The D2RQ Platform is a system for accessing relational databases as virtual, read-only RDF graphs. It offers RDF-based access to the content of relational databases without having to replicate it into an RDF store. Using D2RQ you can:

  • query a non-RDF database using SPARQL
  • access the content of the database as Linked Data over the Web
  • create custom dumps of the database in RDF formats for loading into an RDF store
  • access information in a non-RDF database using the Apache Jena API

D2RQ is Open Source software and published under the Apache license. The source code is available on GitHub. You can contact the dev team through the issue tracker.

This is a Docker image based on the official Docker Java 7 JRE image itself based on Alpine linux, an incredibly lightweight distribution.

Build

The image can be built directly and comes with database drivers for MySQL and Postgres.

docker build -t your_repo:d2rq .

For more complex scenarios, the image can be used as a base image, e.g. using the common Docker wait-for-it.sh script to allow waiting for a linked MariaDB container to come up and include a MariaDB JDBC driver:

FROM your_repo:d2rq

COPY wait-for-it.sh ./
COPY mariadb-java-client-1.4.5.jar lib/db-drivers/

Configuration

D2R is configured by way of a mapping file which can itself point to other configuration files such as metadata templates, SQL scripts, transformation tables and ontologies.

An initial configuration file can be generated directly by introspecting the relations in an existing SQL database:

docker run -it your_repo:d2rq ./generate-mapping

Typically, the generated mapping file is then hand edited to make the transformation more naturally reflect RDF and LOD conventions. The resulting configuration file can be placed in config/mapping.ttl for instance.

Running

The image can be used stand-alone with the mapping file in config/mapping.ttl as follows. The default

docker run -p 2020:2020 -v $PWD/config:/var/lib/d2rq -p 2020:2020 -t your_rep:d2rq

Environment Variables

D2R Server does need to be told where it will be hosted by passing the environment variable D2R_BASEURI. This defaults to http://localhost:2020/, but for example using docker-machine on OSX, one could run the container as:

`docker run -v $PWD/config:/var/lib/d2rq --env D2R_BASEURI=http://$(docker-machine ip default)/ -p 80:2020 -t your_rep:d2rq

This would tell D2R Server that its resources are published at the IP address of the local default docker machine VM on default HTTP port 80, forwarding to D2R Server running on port 2020 in the container.


Copyright 2017 Alex Tucker alex@floop.org.uk

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.