Upload Dockerfile
Browse files- Dockerfile +53 -0
Dockerfile
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Phi-4-mini-instruct HuggingFace Space Deployment
|
| 2 |
+
# Best 4B model for agentic work with tool calling support
|
| 3 |
+
# Exposes OpenAI-compatible API on port 7860
|
| 4 |
+
|
| 5 |
+
FROM python:3.11-slim
|
| 6 |
+
|
| 7 |
+
# Set environment variables
|
| 8 |
+
ENV PYTHONUNBUFFERED=1
|
| 9 |
+
ENV MODEL_REPO=unsloth/Phi-4-mini-instruct-GGUF
|
| 10 |
+
ENV MODEL_FILE=Phi-4-mini-instruct-Q4_K_M.gguf
|
| 11 |
+
ENV N_CTX=8192
|
| 12 |
+
ENV N_THREADS=2
|
| 13 |
+
ENV HOST=0.0.0.0
|
| 14 |
+
ENV PORT=7860
|
| 15 |
+
|
| 16 |
+
# Install system dependencies
|
| 17 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 18 |
+
build-essential \
|
| 19 |
+
curl \
|
| 20 |
+
git \
|
| 21 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 22 |
+
|
| 23 |
+
# Set working directory
|
| 24 |
+
WORKDIR /app
|
| 25 |
+
|
| 26 |
+
# Copy the startup script
|
| 27 |
+
COPY script.sh /app/script.sh
|
| 28 |
+
RUN chmod +x /app/script.sh
|
| 29 |
+
|
| 30 |
+
# Install Python dependencies with pre-built wheels for HF Spaces
|
| 31 |
+
RUN pip install --no-cache-dir \
|
| 32 |
+
llama-cpp-python \
|
| 33 |
+
--extra-index-url https://huggingface.co/Luigi/llama-cpp-python-wheels-hf-spaces-free-cpu/resolve/main/
|
| 34 |
+
|
| 35 |
+
# Install additional dependencies for API server
|
| 36 |
+
RUN pip install --no-cache-dir \
|
| 37 |
+
fastapi \
|
| 38 |
+
uvicorn \
|
| 39 |
+
huggingface-hub \
|
| 40 |
+
pydantic
|
| 41 |
+
|
| 42 |
+
# Pre-download the model during build (optional - comment out if build times out)
|
| 43 |
+
# RUN python -c "from huggingface_hub import hf_hub_download; hf_hub_download(repo_id='$MODEL_REPO', filename='$MODEL_FILE', local_dir='/app/models')"
|
| 44 |
+
|
| 45 |
+
# Expose port 7860 (required for HuggingFace Spaces)
|
| 46 |
+
EXPOSE 7860
|
| 47 |
+
|
| 48 |
+
# Health check
|
| 49 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
| 50 |
+
CMD curl -f http://localhost:7860/health || exit 1
|
| 51 |
+
|
| 52 |
+
# Run the startup script
|
| 53 |
+
CMD ["/app/script.sh"]
|