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