Add Dockerfile and document how to run Sentinel in a container#30
Merged
Conversation
Adds a Dockerfile (+ .dockerignore) that installs the sentinel library with the sbert extra and runs the beginner demo by default, plus a "Run with Docker" README section covering build, run, model caching, and custom scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
Close the unterminated Python block in the "Creating a New Index" section and remove a stray closing fence after the aggregation "Notes", which together caused headings and prose (through "How It Works") to render as code. Co-authored-by: Cursor <cursoragent@cursor.com>
Add Dockerfile.cpu that installs the CPU-only torch build (from the PyTorch CPU index) so users who don't need a GPU can build a much smaller image (~1.5-2.5 GB vs ~6-8 GB). Cross-reference it from the default Dockerfile and document both variants (with a comparison table) in the README. Co-authored-by: Cursor <cursoragent@cursor.com>
Normalize blank lines around the dependency sections; no dependency or configuration changes. Co-authored-by: Cursor <cursoragent@cursor.com>
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Dockerfile(default, GPU-capable) that installs thesentinellibrary with thesbertextra (sentence-transformers + torch) via Poetry +poetry.lock, and runs the beginner demo (examples/beginner_demo.py) by default.Dockerfile.cpuvariant that installs the CPU-only torch build (from the PyTorch CPU index) for a much smaller image (~1.5-2.5 GB vs ~6-8 GB) when a GPU isn't needed..dockerignoreto keep the build context small (excludes.git,.venv, caches, editor cruft, etc.).examples/beginner_demo.py(the default container entrypoint), a ~1-screen end-to-end demo that builds a tiny in-memory index and scores example messages.pyproject.toml(no dependency/config changes).Details
python:3.11-slim.Dockerfile: installs Poetry>=2.0,<3.0to match the project'spoetry-core>=2.0.0build backend; dependency install is layered separately from app code so Docker can cache the slow dependency step.Dockerfile.cpu: installs CPU torch first fromhttps://download.pytorch.org/whl/cpu, thenpip install ".[sbert]"so torch stays CPU-only. Note: this variant uses pip (not the lockfile), so it is not fully pinned.sentineluser;HF_HOMEpoints at that user's cache dir so model downloads can be persisted via a mounted volume.Test
Default (GPU-capable) image:
docker build -t sentinel .completes successfully.docker run --rm sentinelruns the beginner demo and prints per-message scores.docker run --rm -v "$(pwd)/.hf-cache:/home/sentinel/.cache/huggingface" sentinelreuses the cached model on a second run.docker run --rm -it sentinel bashdrops into an interactive shell.CPU-only image (
Dockerfile.cpu):docker build -f Dockerfile.cpu -t sentinel:cpu .completes successfully.docker run --rm sentinel:cpuruns the beginner demo and prints per-message scores.docker images sentinel).docker run --rm sentinel:cpu python -c "import torch; print(torch.__version__)"shows a+cpubuild with no CUDA/nvidia packages.