File size: 1,354 Bytes
fffe03d
29cabc6
fffe03d
 
 
 
 
eee5680
fffe03d
 
 
 
 
 
 
 
 
 
 
 
 
dbafe5e
29cabc6
 
 
 
 
 
 
 
fffe03d
 
29cabc6
fffe03d
 
29cabc6
fffe03d
 
c3837de
 
29cabc6
5dddd3e
 
fffe03d
29cabc6
fffe03d
 
 
29cabc6
fffe03d
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 1. Base Image
FROM python:3.10-slim

# 2. Set Environment Variables
ENV PYTHONUNBUFFERED=1
ENV GRADIO_SERVER_NAME="0.0.0.0"
ENV OLLAMA_HOST="0.0.0.0:11434"
ENV HOME=/root  

# 3. Set Working Directory
WORKDIR /app

# 4. Install System Dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    curl \
    ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# 5. Install Ollama
RUN curl -fsSL https://ollama.com/install.sh | sh

# 6. Create the .ollama directory for the root user and set permissions
#    Ollama needs to create its 'id_ed25519' key and 'models' subdir here.
#    We ensure the base .ollama directory exists and is writable by root.
RUN mkdir -p /root/.ollama && \
    chown -R root:root /root/.ollama && \
    chmod -R 700 /root/.ollama # rwx for owner (root), no access for others

# 7. Copy Application Requirements
COPY requirements.txt .

# 8. Install Python Dependencies
RUN pip install --no-cache-dir -r requirements.txt

# 9. Copy Your Application Code AND startup script
COPY app.py .
COPY startup.sh .
RUN chmod +x ./startup.sh

# 10. Define Models to Pull (as an Argument with a default list)
ARG OLLAMA_PULL_MODELS="qwen3:1.7b qwen3:0.6b" 
ENV OLLAMA_PULL_MODELS=${OLLAMA_PULL_MODELS} 

# 11. Expose Ports
EXPOSE 11434
EXPOSE 7860

# 12. Entrypoint/Startup Script
ENTRYPOINT ["./startup.sh"]