This project provides a simple Dockerized RDF endpoint that serves an .rdf
file an provides an SPARQL Endpoint based on vemonet/rdflib-endpoint
-
SPARQL Features:
- Integrated YASGUI editor with multi-tab support
- Pre-configured example queries
- Machine-readable SPARQL endpoint
-
Easy Deployment:
- Docker and Kubernetes ready
- Environment-based configuration
-
Security & Performance:
- NGINX reverse proxy
- SSL/TLS support
- Configurable CORS
-
RDF Catalog Serving:
- Serves Catalog
.rdf
files with properContent-Type: application/rdf+xml
- Compatible with DCAT-AP federators and RDF parsers
- Serves Catalog
Use Codespaces to test easy-rdf-endpoint
in your browser
Requirements:
Before starting the deployment, you'll need to set up a .env
file. This file is crucial as it contains environment variables that the application needs to run properly.
-
Clone project
cd /path/to/my/project git clone https://github.com/mjanez/easy-rdf-endpoint.git & cd easy-rdf-endpoint
-
Push your RDF catalog in folder: ./data
-
Copy the
.env.example
template and modify the resulting.env
to suit your needs.cp .env.example .env
Adjust the vars as necessary, example the server name if not use
localhost
:# Server Configuration PROXY_SERVER_NAME=my-example-sparql-server.org # RDF of filename in folder ./data CATALOG_FILE=my-custom-catalog.rdf # Edit your custom SPARQL queries that load as tabs at startup EXAMPLE_SPARQL_QUERIES='{ "HVD info": { "query": "prefix dct: <http://purl.org/dc/terms/>\nprefix dcatap: <http://data.europa.eu/r5r/>\nprefix dcat: <http://www.w3.org/ns/dcat#>\n\nselect distinct ?title ?hvdCategory ?applicableLegislation ?accessService ?accessURL ?license\nwhere {\n ?catalogo ?cp ?d.\n\n # Dataset y su categoría HVD\n ?d dcatap:applicableLegislation <http://data.europa.eu/eli/reg_impl/2023/138/oj>.\n ?d a dcat:Dataset.\n optional { ?d dcatap:hvdCategory ?hvdCategory. }\n \n # Distribution and its props\n ?d dcat:distribution ?dist.\n ?dist dcatap:applicableLegislation <http://data.europa.eu/eli/reg_impl/2023/138/oj>.\n \n optional { \n ?dist dct:title ?title.\n FILTER(langMatches(lang(?title), \"en\"))\n } \n optional { ?dist dcatap:applicableLegislation ?applicableLegislation. } \n optional { ?dist dcat:accessURL ?accessURL. } \n optional { ?dist dcat:accessService ?accessService. } \n optional { ?dist dct:license ?license. } \n}\nORDER BY ?dist" }, "Count stats": { "query": "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\nPREFIX dcat: <http://www.w3.org/ns/dcat#>\nPREFIX dct: <http://purl.org/dc/terms/>\n\nSELECT \n (COUNT(DISTINCT ?dataset) AS ?totalDatasets)\n (COUNT(DISTINCT ?distribution) AS ?totalDistributions)\n (COUNT(DISTINCT ?dataservice) AS ?totalDataservices)\n (COUNT(DISTINCT ?publisher) AS ?totalPublishers)\nWHERE {\n {\n ?dataset a dcat:Dataset .\n OPTIONAL { ?dataset dct:publisher ?publisher }\n OPTIONAL { ?dataset dcat:distribution ?distribution }\n }\n UNION\n {\n ?dataservice a dcat:DataService ;\n dcat:servesDataset ?dataset .\n }\n}" }, "Query types": { "query": "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\nPREFIX dct: <http://purl.org/dc/terms/>\nSELECT DISTINCT ?type ?label (COUNT(?s) as ?count) ?comment WHERE {\n ?s rdf:type ?type .\n OPTIONAL { ?type rdfs:label ?label }\n OPTIONAL { ?type rdfs:comment ?comment }\n} \nGROUP BY ?type ?label ?comment\nORDER BY DESC(?count)\nLIMIT 10" } }'
-
Build & up the container.
docker compose up -d
Then, access your RDF file an endpoints.
The endpoints will be available at:
- Landing page
http://localhost:5000
- Access your RDF file at:
http://localhost:5000/catalog
- Default query editor (Yasgui):
http://localhost:5000/sparql-editor
- SPARQL endpoint:
http://localhost:5000/sparql
- Access your RDF file at:
/easy-rdf-endpoint
│── /data/catalog.rdf # Your Catalog RDF file (replace with your own)
│── /doc/ # References, as images or documents, used in repo
│── /easy-rdf-endpoint/ # RDF+SPARQL Endpoint setup
│── /nginx/ # NGINX docker setup
│── /src/ # Now using NGINX instead of the old RDF serving mode
│── .env.example # Sample ENVVars file for use with Docker Compose
│── docker-compose.yml # Docker Compose config
│── README.md # Documentation
Tip
- Replace
catalog.rdf
with your actual RDF file. - Works with Codespaces, Docker, Kubernetes, and any containerized environment.
To update the local SSL certificate, follow these steps:
- Generate a new certificate and private key:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout nginx/setup/easy-rdf-endpoint_local.key \
-out nginx/setup/easy-rdf-endpoint_local.crt \
-subj "/C=ES/ST=Madrid/L=Madrid/O=Development/CN=localhost"
- Verify that the files have been created correctly:
ls -l nginx/setup/easy-rdf-endpoint_local.*
- Restart the
nginx
container to apply the changes:
docker compose restart nginx
Caution
This certificate is for local development only. In production, use a valid certificate from a certificate authority.
This project supports development using DevContainers, which provides a consistent development environment for all contributors.
Requirements:
- Clone the repository:
git clone https://github.com/mjanez/easy-rdf-endpoint.git
cd easy-rdf-endpoint
- Open in VS Code:
code .
- When prompted "Reopen in Container", click "Reopen in Container". Alternatively:
- Press
F1
- Type "Remote-Containers: Reopen in Container"
- Press Enter
- Press
VS Code will build and start the development container. This may take a few minutes the first time.
The development container includes:
- Python 3.11 environment
- Required Python packages pre-installed
- Popular VS Code extensions for Python/Docker development
- Git configuration
- Port forwarding for the application
Once inside the container you can:
- Run the application:
exec gunicorn --bind 0.0.0.0:5000 app:app
- Modify the
easy-rdf-endpoint/setup/rdflib-endpoint/sparql_override.py
- Execute SPARQL queries:
http://localhost:5000/sparql
- Debug with VS Code's integrated debugger
Some icons used in this project are from:
- SVG Repo under CC Attribution License
- ckanext-schemingdcat repository
This work is a developed inspired by rdflib-endpoint by Vincent Emonet, licensed under MIT License.
This derivative work is licensed under Creative Commons Attribution 4.0 International License.