File size: 1,349 Bytes
5cd8a42
 
37c6f87
5cd8a42
 
 
 
37c6f87
 
5cd8a42
 
 
 
 
 
 
 
77b4dba
5cd8a42
 
 
 
3b1f63b
 
5cd8a42
6da83c8
5cd8a42
 
 
 
 
37c6f87
77b4dba
 
 
0950c54
5cd8a42
6da83c8
5cd8a42
 
 
 
 
77b4dba
5cd8a42
77b4dba
 
5cd8a42
 
 
b04a975
5cd8a42
 
 
f4b92bb
5cd8a42
 
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
51
52
53
54
55
56
57
# Use Ubuntu as base image for better Ollama compatibility
FROM ubuntu:22.04

# Prevent interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive

# Set working directory
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    curl \
    python3 \
    python3-pip \
    python3-venv \
    wget \
    ca-certificates \
    sudo \
    && rm -rf /var/lib/apt/lists/*

# Create and activate virtual environment
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

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

# Create app directory and set permissions
RUN mkdir -p /app/.ollama && \
    chmod 755 /app/.ollama

# Copy application files
COPY app.py .
COPY startup.sh .

# Make startup script executable
RUN chmod +x startup.sh

# Set environment variables for Ollama
ENV OLLAMA_HOST=0.0.0.0:11434
ENV OLLAMA_MODELS=/app/.ollama/models
ENV OLLAMA_HOME=/app/.ollama

# Expose ports
EXPOSE 7860 11434

# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
    CMD curl -f http://localhost:7860/health || exit 1

# Start both Ollama server and FastAPI app
CMD ["./startup.sh"]