Docker
model2vec-serve ships with a multi-stage Dockerfile that produces a small runtime image.
Build
docker build -t model2vec-serve:latest .The build stage uses rust:1.85-slim and installs the native dependencies required by model2vec-rs. The runtime stage uses debian:bookworm-slim and only the compiled binary plus CA certificates.
Run
docker run -p 8080:8080 \
-e MODEL=minishlab/potion-multilingual-128M \
model2vec-serve:latestWith an API key
docker run -p 8080:8080 \
-e MODEL=minishlab/potion-multilingual-128M \
-e API_KEY=my-secret-key \
model2vec-serve:latestWith extra CLI arguments
Pass them after the image name:
docker run -p 8080:8080 \
-e MODEL=minishlab/potion-multilingual-128M \
model2vec-serve:latest \
--max-batch-size 128 \
--log-level debugWith a local model
Mount the model directory into the container and point --model at the mount path:
docker run -p 8080:8080 \
-v /path/to/local/model:/models/my-model \
-e MODEL=/models/my-model \
model2vec-serve:latestGitHub Container Registry
Pre-built images are published to the GitHub Container Registry (GHCR) on every GitHub release. The image name is derived from the repository:
ghcr.io/freinold/model2vec-servePull a released image
Replace <version> with the desired release tag (for example v0.1.0):
docker pull ghcr.io/freinold/model2vec-serve:<version>The latest tag is also pushed for the most recent release, but pinning to a semantic version is recommended for reproducible deployments.
Run the published image
docker run -p 8080:8080 \
-e MODEL=minishlab/potion-multilingual-128M \
ghcr.io/freinold/model2vec-serve:<version>Image size
The final image is designed to stay lightweight enough to start and serve requests with modest resource limits (around 1 CPU and 1 GiB memory, depending on the model).
Release process
Releases are automated with release-plz:
- Commit changes using Conventional Commits.
release-plzopens a release PR that bumpsCargo.tomland updatesCHANGELOG.md.- After the release PR is merged,
release-plzcreates a GitHub release and git tag. - The
docker.ymlworkflow builds and pushes the container image for the new tag to GHCR.
