Spaces:
Sleeping
Sleeping
Create Dockerfile
Browse files- Dockerfile +31 -0
Dockerfile
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use a lightweight Python base
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Set working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Install system tools (curl is needed to install Ollama)
|
| 8 |
+
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
+
# Install Ollama
|
| 11 |
+
RUN curl -fsSL https://ollama.com/install.sh | sh
|
| 12 |
+
|
| 13 |
+
# Install Python API requirements
|
| 14 |
+
RUN pip install --no-cache-dir fastapi uvicorn requests
|
| 15 |
+
|
| 16 |
+
# Copy your API code
|
| 17 |
+
COPY . .
|
| 18 |
+
|
| 19 |
+
# Create a start script to handle the background process
|
| 20 |
+
RUN echo '#!/bin/bash' > start.sh && \
|
| 21 |
+
echo 'ollama serve &' >> start.sh && \
|
| 22 |
+
echo 'sleep 5' >> start.sh && \
|
| 23 |
+
echo 'ollama pull granite-code:2b' >> start.sh && \
|
| 24 |
+
echo 'uvicorn api:app --host 0.0.0.0 --port 7860' >> start.sh && \
|
| 25 |
+
chmod +x start.sh
|
| 26 |
+
|
| 27 |
+
# Hugging Face expects port 7860
|
| 28 |
+
EXPOSE 7860
|
| 29 |
+
|
| 30 |
+
# Run the start script
|
| 31 |
+
CMD ["./start.sh"]
|