File size: 940 Bytes
1a5c031
 
 
48a0e7a
31011ed
1a5c031
 
 
 
48a0e7a
31011ed
 
48a0e7a
 
 
 
 
 
 
 
 
 
 
31011ed
1a5c031
 
48a0e7a
1a5c031
 
 
 
48a0e7a
 
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 an official Python runtime as a parent image
FROM python:3.10-slim

# Install curl and other dependencies required 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

# Pre-download the llama3.2:1b model during build
RUN ollama pull llama3.2:1b

# Set up non-root user as required by Hugging Face Spaces
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH="/home/user/.local/bin:$PATH"

# Set working directory
WORKDIR /home/user/app

# Copy and install Python dependencies
COPY --chown=user:user requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy the app code
COPY --chown=user:user app.py .

# Expose the Streamlit port
EXPOSE 8501

# Start Ollama in the background and then run Streamlit
CMD ollama serve & sleep 5 && streamlit run app.py --server.port 8501 --server.address 0.0.0.0