Spaces:
Sleeping
Sleeping
Delete Dockerfile
Browse files- Dockerfile +0 -84
Dockerfile
DELETED
|
@@ -1,84 +0,0 @@
|
|
| 1 |
-
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 2 |
-
# Dockerfile β Children's Learning Router Service
|
| 3 |
-
# Target: Hugging Face Spaces (CPU-only, Docker SDK)
|
| 4 |
-
# Port: 7860 (required by HF Spaces)
|
| 5 |
-
#
|
| 6 |
-
# Model delivery: via `preload_from_hub` in README.md
|
| 7 |
-
# HF Spaces downloads Qwen/Qwen2.5-1.5B-Instruct before container start
|
| 8 |
-
# and places it under /repo-cache (HF_HOME=/repo-cache).
|
| 9 |
-
# No in-build download is needed or possible (build env has no internet).
|
| 10 |
-
#
|
| 11 |
-
# OOM mitigation: packages are installed in small isolated groups so pip's
|
| 12 |
-
# dependency resolver never spikes RAM. --no-cache-dir and --no-compile
|
| 13 |
-
# keep peak memory low throughout the build.
|
| 14 |
-
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 15 |
-
|
| 16 |
-
FROM python:3.10-slim
|
| 17 |
-
|
| 18 |
-
# ββ System packages βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 19 |
-
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 20 |
-
build-essential \
|
| 21 |
-
git \
|
| 22 |
-
curl \
|
| 23 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 24 |
-
|
| 25 |
-
# ββ Working directory βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 26 |
-
WORKDIR /app
|
| 27 |
-
|
| 28 |
-
# ββ Pip hygiene: upgrade pip/wheel first (small, fast) βββββββββββββββββββ
|
| 29 |
-
RUN pip install --no-cache-dir --no-compile --upgrade pip wheel
|
| 30 |
-
|
| 31 |
-
# ββ 1 of 5 Β· CPU-only PyTorch (largest wheel β install alone) ββββββββββββ
|
| 32 |
-
RUN pip install --no-cache-dir --no-compile \
|
| 33 |
-
torch==2.3.1 \
|
| 34 |
-
--index-url https://download.pytorch.org/whl/cpu
|
| 35 |
-
|
| 36 |
-
# ββ 2 of 5 Β· HuggingFace stack (transformers pulls in tokenizers etc.) βββ
|
| 37 |
-
RUN pip install --no-cache-dir --no-compile \
|
| 38 |
-
transformers==4.46.3 \
|
| 39 |
-
accelerate==1.1.1
|
| 40 |
-
|
| 41 |
-
# ββ 3 of 5 Β· Serialisation libs ββββββββββββββββββββββββββββββββββββββββββ
|
| 42 |
-
RUN pip install --no-cache-dir --no-compile \
|
| 43 |
-
sentencepiece==0.2.0 \
|
| 44 |
-
protobuf==5.28.3
|
| 45 |
-
|
| 46 |
-
# ββ 4 of 5 Β· Async HTTP client βββββββββββββββββββββββββββββββββββββββββββ
|
| 47 |
-
RUN pip install --no-cache-dir --no-compile \
|
| 48 |
-
httpx==0.27.2
|
| 49 |
-
|
| 50 |
-
# ββ 5 of 5 Β· Web framework + ASGI server βββββββββββββββββββββββββββββββββ
|
| 51 |
-
RUN pip install --no-cache-dir --no-compile \
|
| 52 |
-
fastapi==0.115.0 \
|
| 53 |
-
gunicorn==22.0.0 \
|
| 54 |
-
uvicorn[standard]==0.30.6
|
| 55 |
-
|
| 56 |
-
# ββ Application code ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 57 |
-
COPY app.py .
|
| 58 |
-
|
| 59 |
-
# ββ HuggingFace Spaces: run as non-root user (UID 1000) ββββββββββββββββββ
|
| 60 |
-
RUN useradd -m -u 1000 hfuser \
|
| 61 |
-
&& chown -R hfuser:hfuser /app
|
| 62 |
-
USER hfuser
|
| 63 |
-
|
| 64 |
-
# ββ Runtime config ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 65 |
-
# HF Spaces sets HF_HOME=/repo-cache and places preload_from_hub models
|
| 66 |
-
# there before the container starts. Pointing both vars here ensures
|
| 67 |
-
# transformers and huggingface_hub find the pre-downloaded model weights
|
| 68 |
-
# without any network access at runtime.
|
| 69 |
-
ENV PYTHONUNBUFFERED=1 \
|
| 70 |
-
PYTHONDONTWRITEBYTECODE=1 \
|
| 71 |
-
HF_HOME=/repo-cache \
|
| 72 |
-
TRANSFORMERS_CACHE=/repo-cache/hub
|
| 73 |
-
|
| 74 |
-
EXPOSE 7860
|
| 75 |
-
|
| 76 |
-
# ββ Start-up command ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 77 |
-
# Gunicorn + uvicorn worker enables Flask async views.
|
| 78 |
-
# --preload ensures the model is loaded ONCE before workers fork.
|
| 79 |
-
CMD ["gunicorn", "app:app", \
|
| 80 |
-
"--worker-class", "uvicorn.workers.UvicornWorker", \
|
| 81 |
-
"--workers", "1", \
|
| 82 |
-
"--bind", "0.0.0.0:7860", \
|
| 83 |
-
"--timeout", "300", \
|
| 84 |
-
"--preload"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|