-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Docker Compose template for SPARQL endpoint and RDF browser. #97
Merged
dbooth-boston
merged 5 commits into
w3c:master
from
KonradHoeffner:docker-compose-template
Sep 26, 2022
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
47e9bc6
Add Docker Compose template for SPARQL endpoint and RDF browser. Reso…
KonradHoeffner 063cc4e
Update docker/README.md
KonradHoeffner 11ef8a7
Improve formatting of docker/rdf/example.ttl
KonradHoeffner 2315368
Update docker/README.md
KonradHoeffner bee0b51
Use LodView instead of RickView.
KonradHoeffner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DBA_PASSWORD=changeme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Simple template for a Docker Compose setup based on [Virtuoso](https://github.com/openlink/virtuoso-opensource/), providing an RDF store, SPARQL Endpoint, and RDF browser (among other available features) for a quick knowledge base deployment. | ||
|
||
# Localize | ||
|
||
1. Replace `rdf/example.ttl` with your knowledge base | ||
2. Add your namespaces to `initdb.d/setup.sql` | ||
3. Adapt `docker-compose.yml` | ||
4. Copy `.env.dist` to `.env` and change `DBA_PASSWORD` | ||
|
||
# Start to use | ||
|
||
1. Run `docker compose up --build` | ||
2. Test the SPARQL endpoint at [`http://localhost:8890/sparql`](http://localhost:8890/sparql) | ||
2. Test the RDF browser at [`http://localhost:8080/`](http://localhost:8080/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
services: | ||
|
||
virtuoso: | ||
image: openlink/virtuoso-opensource-7 | ||
environment: | ||
- DBA_PASSWORD=${DBA_PASSWORD} | ||
- VIRT_DATABASE_ERRORLOGLEVEL=3 | ||
- VIRT_SPARQL_DEFAULTGRAPH=http://example.org | ||
- VIRT_SPARQL_DEFAULTQUERY=select distinct * {?s ?p ?o.} LIMIT 100 | ||
- VIRT_PARAMETERS_DIRSALLOWED=., /usr/local/virtuoso-opensource/share/virtuoso/vad, /rdf | ||
- VIRT_PLUGINS_-=- | ||
volumes: | ||
- ./rdf:/rdf:ro | ||
- ./initdb.d:/opt/virtuoso-opensource/initdb.d:ro | ||
ports: | ||
- "127.0.0.1:8890:8890" | ||
restart: unless-stopped | ||
|
||
rickview: | ||
image: ghcr.io/konradhoeffner/rickview:master | ||
environment: | ||
- RICKVIEW_KB_FILE=/rdf/example.ttl | ||
- RICKVIEW_TITLE=Example Title | ||
- RICKVIEW_SUBTITLE=Example Subtitle | ||
- RICKVIEW_PREFIX=ex | ||
- RICKVIEW_NAMESPACE=http://example.org/ | ||
- RICKVIEW_EXAMPLES=ExClass ExProperty ExInstance | ||
volumes: | ||
- ./rdf:/rdf:ro | ||
ports: | ||
- "127.0.0.1:8080:8080" | ||
restart: unless-stopped | ||
|
||
volumes: | ||
rdf: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
log_message('Setup: Activate CORS'); | ||
update DB.DBA.HTTP_PATH set HP_OPTIONS = serialize(vector('browse_sheet', '', 'noinherit', 'yes', 'cors', '*', 'cors_restricted', 0)) where HP_LPATH = '/sparql'; | ||
log_message('Setup: Declare namespaces'); | ||
DB.DBA.XML_SET_NS_DECL ('ex', 'http://example.org/', 2); | ||
log_message('Setup: Load data'); | ||
ld_dir_all ('/rdf/', '*.ttl', 'http://example.org'); | ||
rdf_loader_run(); | ||
log_message('Setup: Finished'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | ||
PREFIX owl: <http://www.w3.org/2002/07/owl#> | ||
PREFIX ex: <http://example.org/> | ||
|
||
ex:ExClass | ||
a owl:Class ; | ||
rdfs:comment "an example class"@en ; | ||
rdfs:label "example class"@en . | ||
|
||
ex:ExInstance | ||
a ex:ExClass ; | ||
ex:exProperty 5 ; | ||
rdfs:comment "an example instance."@en ; | ||
rdfs:label "example instance"@en . | ||
|
||
ex:exProperty | ||
a owl:DatatypeProperty ; | ||
rdfs:domain ex:ExClass ; | ||
rdfs:label "Beispielproperty"@de , | ||
"example property"@en . |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TallTed , is there a way to load the namespaces from Turtle files instead? This seems like a rather hokey way to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any Turtle file may contain its own namespaces.
Those loaded via the (SQL)
DB.DBA.XML_SET_NS_DECL()
function are just the presets that are used when no declaration is found in a SPARQL query, as shown for the DBpedia instance.Does that make this seem less hokey?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately no. I understand that it is just setting default namespaces, but it would be much simpler for a user if a Turtle or SPARQL file could simply be provided to do so. After all, that's likely where they'll come from anyway.
But this certainly isn't a show stopper. I was just wondering if it could be simplified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if that would even be possible to implement because in a real-world situation you often load multiple files, which may have conflicting namespaces and then it is not defined, which one would take precedence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pointer?
In practice - do prefix declarations (they aren't namespaces - that's XML!) get redeclared?
http://prefix.cc/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not sure what you mean with pointer, but I try to clarify what I mean and how I understand and use the terms, feel free to correct me with the right terms in case I use the wrong ones:
DB.DBA.XML_SET_NS_DECL
is used in setup.sql to define default prefix to namespace mappings, in case a SPARQL query does not declare the prefix.When we load N-Triples files in
setup.sql
then we have no other choice but to do it this way, because N-Triple files don't contain prefixes.However when we load Turtle or RDF/XML then the question is if it is possible to load them from there.
My argument against that, besides that as far as I know Virtuoso does not support this, is that it it does not make sense to implement it because of the following case:
Example
ld_dir_all ('/rdf/', '*.ttl', 'http://example.org');
rdf
directory containsa.ttl
andb.ttl
http://example.org/ontology/
http://example.org/resource/
Now the namespace mapping for the empty prefix in Virtuoso would be undefined (maybe unpredictable is a better word).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's a good reason for disallowing it. The same problem already exists if the user does this:
The tool could warn if a prefix is redefined differently, but should not warn if it is redefined to have the same value, because it's common to define the same prefixes (the same way) in different files.
Consider this a feature enhancement suggestion. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would argue that at least in this case there can be a defined behavior because the order of statements is deterministic, while in the "*.ttl" example it is either undefined or at least less clear. But I have to pass this feature enhancement suggestion to @TallTed, because I'm not a Virtuoso developer :-)
I don't think there is a succinct way to implement this in the
setup.sql
script itself.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it's only the empty prefix? (and
ex:
!)For all others, what I see out there is strong consistency across datasets.
A PREFIX in Turtle can redefine a prefix mid file. So when loading or concatenated, last prefix wins. Prefixes don't affect the data. Only the presentation.