Skip to content

Commit 1898c0b

Browse files
authored
Add dockerfile. (#4)
1 parent b86e012 commit 1898c0b

File tree

3 files changed

+124
-1
lines changed

3 files changed

+124
-1
lines changed

.dockerignore

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
*.egg-info/
8+
dist/
9+
build/
10+
11+
# Virtual environments
12+
.venv/
13+
venv/
14+
ENV/
15+
env/
16+
17+
# IDE
18+
.vscode/
19+
.idea/
20+
*.swp
21+
*.swo
22+
*~
23+
24+
# Git
25+
.git/
26+
.gitignore
27+
.github/
28+
29+
# Testing
30+
.pytest_cache/
31+
htmlcov/
32+
.coverage
33+
.tox/
34+
35+
# HDT and output files
36+
*.hdt
37+
*.ttl
38+
39+
# Example files
40+
example-inputs/
41+
example-outputs/
42+
43+
# Documentation
44+
*.md
45+
!README.md
46+
47+
# Misc
48+
.DS_Store

Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Build stage: compile dependencies
2+
# Use bullseye (Debian 11) with GCC 10 instead of bookworm with GCC 12+
3+
# rdflib-hdt 3.2 has C++ code missing #include <cstdint>, which fails on newer GCC
4+
FROM python:3.12-bullseye AS builder
5+
6+
# Set working directory
7+
WORKDIR /app
8+
9+
# Install uv for fast, reliable dependency management
10+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
11+
12+
# Set environment variables for uv
13+
ENV UV_COMPILE_BYTECODE=1
14+
15+
# Copy dependency files first for better caching
16+
COPY pyproject.toml uv.lock ./
17+
18+
# Install dependencies (this creates .venv with compiled packages)
19+
# --frozen ensures we use the exact versions from uv.lock
20+
# --no-dev skips development dependencies
21+
RUN uv sync --frozen --no-dev
22+
23+
# Copy the application code
24+
COPY void_hdt/ ./void_hdt/
25+
26+
# Runtime stage: slim image with only runtime dependencies
27+
FROM python:3.12-slim
28+
29+
# Set working directory
30+
WORKDIR /app
31+
32+
# Install uv in runtime image
33+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
34+
35+
# Copy the virtual environment from builder
36+
COPY --from=builder /app/.venv /app/.venv
37+
38+
# Copy the application code
39+
COPY --from=builder /app/void_hdt /app/void_hdt
40+
41+
# Copy project files needed by uv
42+
COPY pyproject.toml uv.lock ./
43+
44+
# Set the entrypoint to use uv run (handles environment automatically)
45+
ENTRYPOINT ["uv", "run", "void-hdt"]
46+
47+
# Default help command if no args provided
48+
CMD ["--help"]

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,15 @@ void-hdt analyzes HDT files and produces comprehensive metadata about RDF datase
1818

1919
## Installation
2020

21-
### Using uv (recommended)
21+
### Using Docker (recommended for quick usage)
22+
23+
Build the Docker image:
24+
25+
```bash
26+
docker build -t void-hdt .
27+
```
28+
29+
### Using uv (for development)
2230

2331
```bash
2432
uv sync
@@ -32,6 +40,25 @@ pip install -e .
3240

3341
## Usage
3442

43+
### Docker
44+
45+
Process an HDT file using Docker:
46+
47+
```bash
48+
docker run --rm -v /path/to/data:/data void-hdt /data/input.hdt -o /data/output.ttl
49+
```
50+
51+
Or with custom dataset URI:
52+
53+
```bash
54+
docker run --rm -v /path/to/data:/data void-hdt \
55+
/data/input.hdt \
56+
-o /data/output.ttl \
57+
--dataset-uri http://example.org/mydata
58+
```
59+
60+
### Local Installation
61+
3562
### Command Line
3663

3764
```bash

0 commit comments

Comments
 (0)