Spaces:
Sleeping
Sleeping
Upload Dockerfile with huggingface_hub
Browse files- Dockerfile +12 -7
Dockerfile
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
-
# Install system dependencies
|
| 4 |
RUN apt-get update && apt-get install -y \
|
| 5 |
curl \
|
| 6 |
ca-certificates \
|
|
|
|
| 7 |
&& rm -rf /var/lib/apt/lists/*
|
| 8 |
|
| 9 |
# Install Ollama
|
|
@@ -19,25 +20,29 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
| 19 |
# Copy application code
|
| 20 |
COPY app.py .
|
| 21 |
|
| 22 |
-
# Create startup script
|
| 23 |
RUN echo '#!/bin/bash\n\
|
| 24 |
set -e\n\
|
| 25 |
echo "Starting Ollama service..."\n\
|
| 26 |
ollama serve &\n\
|
| 27 |
OLLAMA_PID=$!\n\
|
| 28 |
echo "Waiting for Ollama to be ready..."\n\
|
| 29 |
-
sleep
|
| 30 |
-
echo "Pulling model deepseek-r1:1.5b..."\n\
|
| 31 |
-
ollama pull deepseek-r1:1.5b\n\
|
| 32 |
echo "Model ready. Starting FastAPI server..."\n\
|
| 33 |
-
exec uvicorn app:app --host 0.0.0.0 --port 7860 --workers 1 --timeout-keep-alive 300\n\
|
| 34 |
' > /app/start.sh && chmod +x /app/start.sh
|
| 35 |
|
| 36 |
# Expose port
|
| 37 |
EXPOSE 7860
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
# Health check
|
| 40 |
-
HEALTHCHECK --interval=30s --timeout=10s --start-period=
|
| 41 |
CMD curl -f http://localhost:7860/health || exit 1
|
| 42 |
|
| 43 |
# Start services
|
|
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
+
# Install system dependencies including zstd for Ollama
|
| 4 |
RUN apt-get update && apt-get install -y \
|
| 5 |
curl \
|
| 6 |
ca-certificates \
|
| 7 |
+
zstd \
|
| 8 |
&& rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
# Install Ollama
|
|
|
|
| 20 |
# Copy application code
|
| 21 |
COPY app.py .
|
| 22 |
|
| 23 |
+
# Create startup script with no-cache options
|
| 24 |
RUN echo '#!/bin/bash\n\
|
| 25 |
set -e\n\
|
| 26 |
echo "Starting Ollama service..."\n\
|
| 27 |
ollama serve &\n\
|
| 28 |
OLLAMA_PID=$!\n\
|
| 29 |
echo "Waiting for Ollama to be ready..."\n\
|
| 30 |
+
sleep 8\n\
|
| 31 |
+
echo "Pulling model deepseek-r1:1.5b (no cache)..."\n\
|
| 32 |
+
OLLAMA_NOHISTORY=1 ollama pull deepseek-r1:1.5b\n\
|
| 33 |
echo "Model ready. Starting FastAPI server..."\n\
|
| 34 |
+
exec uvicorn app:app --host 0.0.0.0 --port 7860 --workers 1 --timeout-keep-alive 300 --no-access-log\n\
|
| 35 |
' > /app/start.sh && chmod +x /app/start.sh
|
| 36 |
|
| 37 |
# Expose port
|
| 38 |
EXPOSE 7860
|
| 39 |
|
| 40 |
+
# Disable Ollama telemetry and history
|
| 41 |
+
ENV OLLAMA_NOHISTORY=1
|
| 42 |
+
ENV OLLAMA_FLASH_ATTENTION=1
|
| 43 |
+
|
| 44 |
# Health check
|
| 45 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=90s --retries=3 \
|
| 46 |
CMD curl -f http://localhost:7860/health || exit 1
|
| 47 |
|
| 48 |
# Start services
|