oki692 commited on
Commit
6a3016a
·
verified ·
1 Parent(s): 86ee793

Upload Dockerfile with huggingface_hub

Browse files
Files changed (1) hide show
  1. Dockerfile +50 -0
Dockerfile ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
11
+ RUN curl -fsSL https://ollama.com/install.sh | sh
12
+
13
+ # Set working directory
14
+ WORKDIR /app
15
+
16
+ # Copy requirements and install Python dependencies
17
+ COPY requirements.txt .
18
+ RUN pip install --no-cache-dir -r requirements.txt
19
+
20
+ # Copy application code
21
+ COPY app.py .
22
+
23
+ # Create startup script
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..."\n\
32
+ OLLAMA_NOHISTORY=1 ollama pull deepseek-r1:1.5b\n\
33
+ echo "Model ready. Starting FastAPI proxy..."\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
+ ENV OLLAMA_HOST=0.0.0.0:11434
44
+
45
+ # Health check
46
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=90s --retries=3 \
47
+ CMD curl -f http://localhost:7860/ || exit 1
48
+
49
+ # Start services
50
+ CMD ["/app/start.sh"]