diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index ce680ccafd..968e32469a 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -15,3 +15,7 @@ services: - "6020:6379" volumes: - ./redis-volume:/data + graphdb: + image: graphdb + ports: + - "6021:7200" diff --git a/docker/graphdb/Dockerfile b/docker/graphdb/Dockerfile new file mode 100644 index 0000000000..dfcbe7e622 --- /dev/null +++ b/docker/graphdb/Dockerfile @@ -0,0 +1,5 @@ +FROM ontotext/graphdb:10.5.1 +RUN mkdir -p /opt/graphdb/dist/data/repositories/langchain +COPY config.ttl /opt/graphdb/dist/data/repositories/langchain/ +COPY graphdb_create.sh /run.sh +ENTRYPOINT bash /run.sh diff --git a/docker/graphdb/config.ttl b/docker/graphdb/config.ttl new file mode 100644 index 0000000000..dcbdeeebe1 --- /dev/null +++ b/docker/graphdb/config.ttl @@ -0,0 +1,46 @@ +@prefix rdfs: . +@prefix rep: . +@prefix sr: . +@prefix sail: . +@prefix graphdb: . + +[] a rep:Repository ; + rep:repositoryID "langchain" ; + rdfs:label "" ; + rep:repositoryImpl [ + rep:repositoryType "graphdb:SailRepository" ; + sr:sailImpl [ + sail:sailType "graphdb:Sail" ; + + graphdb:read-only "false" ; + + # Inference and Validation + graphdb:ruleset "empty" ; + graphdb:disable-sameAs "true" ; + graphdb:check-for-inconsistencies "false" ; + + # Indexing + graphdb:entity-id-size "32" ; + graphdb:enable-context-index "false" ; + graphdb:enablePredicateList "true" ; + graphdb:enable-fts-index "false" ; + graphdb:fts-indexes ("default" "iri") ; + graphdb:fts-string-literals-index "default" ; + graphdb:fts-iris-index "none" ; + + # Queries and Updates + graphdb:query-timeout "0" ; + graphdb:throw-QueryEvaluationException-on-timeout "false" ; + graphdb:query-limit-results "0" ; + + # Settable in the file but otherwise hidden in the UI and in the RDF4J console + graphdb:base-URL "http://example.org/owlim#" ; + graphdb:defaultNS "" ; + graphdb:imports "" ; + graphdb:repository-type "file-repository" ; + graphdb:storage-folder "storage" ; + graphdb:entity-index-size "10000000" ; + graphdb:in-memory-literal-properties "true" ; + graphdb:enable-literal-index "true" ; + ] + ]. diff --git a/docker/graphdb/graphdb_create.sh b/docker/graphdb/graphdb_create.sh new file mode 100644 index 0000000000..52ffe8ad74 --- /dev/null +++ b/docker/graphdb/graphdb_create.sh @@ -0,0 +1,28 @@ +#! /bin/bash +REPOSITORY_ID="langchain" +GRAPHDB_URI="http://localhost:7200/" + +echo -e "\nUsing GraphDB: ${GRAPHDB_URI}" + +function startGraphDB { + echo -e "\nStarting GraphDB..." + exec /opt/graphdb/dist/bin/graphdb +} + +function waitGraphDBStart { + echo -e "\nWaiting GraphDB to start..." + for _ in $(seq 1 5); do + CHECK_RES=$(curl --silent --write-out '%{http_code}' --output /dev/null ${GRAPHDB_URI}/rest/repositories) + if [ "${CHECK_RES}" = '200' ]; then + echo -e "\nUp and running" + break + fi + sleep 30s + echo "CHECK_RES: ${CHECK_RES}" + done +} + + +startGraphDB & +waitGraphDBStart +wait diff --git a/docker/makefile b/docker/makefile new file mode 100644 index 0000000000..d578580c32 --- /dev/null +++ b/docker/makefile @@ -0,0 +1,12 @@ +# Makefile + +build_graphdb: + docker build --tag graphdb ./graphdb + +start_graphdb: + docker-compose up -d graphdb + +down: + docker-compose down -v --remove-orphans + +.PHONY: build_graphdb start_graphdb down