|
3 | 3 | ## Overview
|
4 | 4 | This project provides a simple **Dockerized RDF endpoint** that serves an `.rdf` file with the correct `Content-Type: application/rdf+xml`, ensuring compatibility with **DCAT-AP federators** and **RDF parsers** like `rdflib`.
|
5 | 5 |
|
6 |
| -## Quick Start |
7 |
| -### Run with Docker |
8 |
| -```sh |
9 |
| -docker build -t rdf-server . |
10 |
| -docker run -p 5000:5000 -v $(pwd)/catalog.rdf:/app/catalog.rdf rdf-server |
11 |
| -``` |
12 | 6 |
|
13 |
| -Then, access your RDF file at: |
| 7 | +## Quick Start |
| 8 | +Use [Codespaces](https://github.com/features/codespaces) to test `easy-rdf-endpoint` in your browser |
| 9 | +<center><a href='https://codespaces.new/mjanez/easy-rdf-endpoint'><img src='https://github.com/codespaces/badge.svg' alt='GitHub Codespaces' style={{maxWidth: '100%'}}/></a></center> |
14 | 10 |
|
15 |
| - 👉 `http://localhost:5000/catalog.rdf` |
| 11 | +## Getting started |
| 12 | +**Requirements**: |
| 13 | +* [Docker](https://docs.docker.com/get-docker/) |
16 | 14 |
|
17 |
| -### Run with Docker Compose (Optional) |
18 |
| -If you prefer `docker-compose`, use: |
| 15 | +### Clone and configure |
| 16 | +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. |
19 | 17 |
|
20 |
| -```sh |
21 |
| -docker-compose up -d |
22 |
| -``` |
23 |
| ---- |
| 18 | +1. Clone project |
| 19 | + ```shell |
| 20 | + cd /path/to/my/project |
| 21 | + git clone https://github.com/mjanez/easy-rdf-endpoint.git & cd ckan-docker |
| 22 | + ``` |
24 | 23 |
|
25 |
| -## **🛠 Project Structure** |
26 |
| -``` |
27 |
| -/rdf-server |
28 |
| -│── catalog.rdf # Your RDF file (replace with your own) |
29 |
| -│── app.py # Flask server to serve RDF |
30 |
| -│── Dockerfile # Docker setup |
31 |
| -│── requirements.txt # Python dependencies |
32 |
| -│── docker-compose.yml # Optional: Docker Compose config |
33 |
| -│── README.md # Documentation |
34 |
| -``` |
35 |
| - |
36 |
| ---- |
37 |
| - |
38 |
| -## Code Explanation |
| 24 | +2. Copy the `.env.example` template and modify the resulting `.env` to suit your needs. |
39 | 25 |
|
40 |
| -### Flask App (`app.py`) |
41 |
| -A minimal Flask server to serve `catalog.rdf` with the correct `Content-Type`. |
| 26 | + ```shell |
| 27 | + cp .env.example .env |
| 28 | + ``` |
42 | 29 |
|
43 |
| -```python |
44 |
| -from flask import Flask, send_file |
| 30 | + Adjust the vars as necessary |
| 31 | + ```ini |
| 32 | + # Host Ports |
| 33 | + SV_PORT_HOST=5000 |
45 | 34 |
|
46 |
| -app = Flask(__name__) |
| 35 | + # Options |
| 36 | + CATALOG_FILE=catalog.rdf |
| 37 | + ``` |
47 | 38 |
|
48 |
| -@app.route("/catalog.rdf") |
49 |
| -def serve_rdf(): |
50 |
| - return send_file("catalog.rdf", mimetype="application/rdf+xml") |
| 39 | +3. Build & up the container. |
51 | 40 |
|
52 |
| -if __name__ == "__main__": |
53 |
| - app.run(host="0.0.0.0", port=5000) |
| 41 | +```sh |
| 42 | +docker compose up -d |
54 | 43 | ```
|
55 | 44 |
|
56 |
| ---- |
57 |
| - |
58 |
| -### Dockerfile |
59 |
| -This Dockerfile creates a lightweight Flask container. |
60 |
| - |
61 |
| -```dockerfile |
62 |
| -# Use lightweight Python image |
63 |
| -FROM python:3.9-slim |
64 |
| - |
65 |
| -# Set working directory |
66 |
| -WORKDIR /app |
67 |
| - |
68 |
| -# Copy required files |
69 |
| -COPY app.py requirements.txt catalog.rdf . |
70 |
| - |
71 |
| -# Install dependencies |
72 |
| -RUN pip install -r requirements.txt |
73 |
| - |
74 |
| -# Expose port |
75 |
| -EXPOSE 5000 |
| 45 | +Then, access your RDF file at: |
76 | 46 |
|
77 |
| -# Run Flask server |
78 |
| -CMD ["python", "app.py"] |
79 |
| -``` |
| 47 | + 👉 `http://localhost:5000/catalog.rdf` |
80 | 48 |
|
81 | 49 | ---
|
82 | 50 |
|
83 |
| -### Python Dependencies (`requirements.txt`) |
84 |
| -```txt |
85 |
| -flask |
| 51 | +## Project Structure |
86 | 52 | ```
|
87 |
| - |
88 |
| ---- |
89 |
| - |
90 |
| -### Docker Compose (Optional) |
91 |
| -For easier deployment using `docker-compose`. |
92 |
| - |
93 |
| -```yaml |
94 |
| -version: '3.8' |
95 |
| -services: |
96 |
| - rdf-server: |
97 |
| - build: . |
98 |
| - ports: |
99 |
| - - "5000:5000" |
100 |
| - volumes: |
101 |
| - - ./catalog.rdf:/app/catalog.rdf |
| 53 | +/rdf-server |
| 54 | +│── /data/catalog.rdf # Your RDF file (replace with your own) |
| 55 | +│── /scr/app.py # Flask server to serve RDF |
| 56 | +│── /src/requirements.txt # Python dependencies |
| 57 | +│── /docker/Dockerfile # Docker setup |
| 58 | +│── docker-compose.yml # Docker Compose config |
| 59 | +│── README.md # Documentation |
102 | 60 | ```
|
103 | 61 |
|
104 |
| ---- |
105 |
| -
|
106 |
| -## Deploy in Codespaces |
107 |
| -1. Open **GitHub Codespaces**. |
108 |
| -2. Clone this repository. |
109 |
| -3. Run: |
110 |
| - ```sh |
111 |
| - docker-compose up -d |
112 |
| - ``` |
113 |
| -4. Access: `http://localhost:5000/catalog.rdf` |
114 |
| - |
115 |
| ---- |
116 |
| - |
117 | 62 | ## Notes
|
118 | 63 | - Replace `catalog.rdf` with your actual RDF file.
|
119 | 64 | - Modify `app.py` if you need additional routes or enhancements.
|
|
0 commit comments