Spaces:
Sleeping
Sleeping
File size: 2,647 Bytes
9be5ad7 834fcbe 9be5ad7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | # TEI Annotator β FastAPI webservice
#
# The image is provider-agnostic: which LLM backend is used depends entirely
# on environment variables set at runtime.
#
# ββ Local deployment (Ollama) ββββββββββββββββββββββββββββββββββββββββββββββββ
#
# docker compose up --build
#
# docker-compose.yml starts an Ollama sidecar, sets OLLAMA_BASE_URL and
# OLLAMA_MODEL=qwen2.5:7b, and maps port 8099 β 7860.
# The model is pulled automatically by Ollama on the first request (~4.7 GB).
#
# To use a different model:
# OLLAMA_MODEL=llama3.2 docker compose up --build
#
# To connect to an Ollama instance running on the host instead of a sidecar:
# docker run -e OLLAMA_BASE_URL=http://host.docker.internal:11434 \
# -e OLLAMA_MODEL=qwen2.5:7b \
# -p 8099:7860 tei-annotator
#
# ββ HuggingFace Spaces (Docker SDK) βββββββββββββββββββββββββββββββββββββββββ
#
# 1. Set sdk: docker and app_port: 7860 in the Space README.md frontmatter.
# 2. Add HF_TOKEN as a Space secret (needs "Make calls to Inference Providers"
# scope β https://huggingface.co/settings/tokens).
# 3. Push this repo; HF Spaces builds and runs the image automatically.
#
# The HF Inference Router (Qwen/Qwen3-14B by default) is used at no cost.
# Add GEMINI_API_KEY, OPENAI_API_KEY, or ANTHROPIC_API_KEY as additional
# Space secrets to unlock more providers.
#
# ββ Other providers ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
#
# Any combination of the following env vars enables the corresponding provider:
# HF_TOKEN, GEMINI_API_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY, KISSKI_API_KEY
#
# See webservice/.env.template for all configuration options.
#
FROM python:3.12-slim
# HuggingFace Spaces requires UID 1000
RUN useradd -m -u 1000 appuser
WORKDIR /app
RUN pip install --no-cache-dir uv
# Copy dependency spec first for layer caching
COPY pyproject.toml README.md ./
# Copy only what the webservice needs at runtime
COPY tei_annotator/ ./tei_annotator/
COPY webservice/ ./webservice/
COPY data/corpus/ ./data/corpus/
RUN uv pip install --system --no-cache -e ".[webservice]"
RUN chown -R appuser:appuser /app
USER appuser
# HuggingFace Spaces default port; remap to taste locally via docker-compose
EXPOSE 7860
ENV PORT=7860 HOST=0.0.0.0
CMD ["python", "webservice/main.py"]
|