Spaces:
Running
Running
# Use an official Python runtime as a parent image | |
FROM python:3.12 | |
# Install system dependencies for 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 Ollama model (requires separate RUN to prevent layer caching issues) | |
RUN ollama pull llama3:latest | |
# Set the working directory in the container | |
WORKDIR /app | |
# Copy requirements.txt into the container | |
COPY requirements.txt . | |
# Install Python dependencies | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy the application code into the container | |
COPY . . | |
# Expose ports for both Streamlit and Ollama | |
EXPOSE 8501 11434 | |
# Set environment variables | |
ENV STREAMLIT_SERVER_PORT=8501 \ | |
STREAMLIT_SERVER_ADDRESS=0.0.0.0 \ | |
PYTHONUNBUFFERED=1 \ | |
OLLAMA_HOST=0.0.0.0:11434 | |
# Start both Ollama and Streamlit | |
CMD ollama serve & streamlit run app.py | |