pavan234Reddy commited on
Commit
128ea0c
·
verified ·
1 Parent(s): f54a68d

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +43 -0
Dockerfile ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ # Install system dependencies including curl for Ollama installation
4
+ RUN apt-get update && apt-get install -y \
5
+ curl \
6
+ && rm -rf /var/lib/apt/lists/*
7
+
8
+ # Install Ollama
9
+ RUN curl -fsSL https://ollama.ai/install.sh | sh
10
+
11
+ # Set working directory
12
+ WORKDIR /app
13
+
14
+ # Copy application files
15
+ COPY requirements.txt .
16
+ COPY main.py .
17
+
18
+ # Install Python dependencies
19
+ RUN pip install --no-cache-dir -r requirements.txt
20
+
21
+ # Create startup script
22
+ RUN echo '#!/bin/bash\n\
23
+ \n\
24
+ # Start Ollama in background\n\
25
+ ollama serve &\n\
26
+ \n\
27
+ # Wait for Ollama to start\n\
28
+ sleep 5\n\
29
+ \n\
30
+ # Pull the model (run in background to not block startup)\n\
31
+ echo "Pulling model gemma3:4b..."\n\
32
+ ollama pull gemma3:4b &\n\
33
+ \n\
34
+ # Start FastAPI server\n\
35
+ echo "Starting FastAPI server..."\n\
36
+ uvicorn main:app --host 0.0.0.0 --port 8000\n\
37
+ ' > start.sh && chmod +x start.sh
38
+
39
+ # Expose port
40
+ EXPOSE 8000
41
+
42
+ # Start the application
43
+ CMD ["./start.sh"]