File size: 1,672 Bytes
5fcc1da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
091341b
5fcc1da
 
 
 
 
732ab0a
e3ad131
732ab0a
 
e3ad131
732ab0a
 
e3ad131
732ab0a
5fcc1da
 
 
 
091341b
 
 
 
5fcc1da
 
 
 
a68b23d
5fcc1da
 
 
 
 
 
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
58
59
60
61
62
63
64
65
# 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 \
    dos2unix \
    && 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

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

# Create the config directory if it doesn't exist
RUN mkdir -p /home/user/.config/kaggle

# Move the file from .kaggle to the correct location
RUN mv ~/.kaggle/kaggle.json /home/user/.config/kaggle/kaggle.json

# Set proper permissions
RUN chmod 600 /home/user/.config/kaggle/kaggle.json

# Fix line endings and make startup script executable
RUN dos2unix startup.sh && chmod +x startup.sh

# Set environment variables for Ollama (using /tmp for guaranteed write access)
# ENV HOME=/tmp
# ENV OLLAMA_HOST=0.0.0.0:11434
# ENV OLLAMA_MODELS=/tmp/ollama/models
# ENV OLLAMA_HOME=/tmp/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 ["/bin/bash", "./startup.sh"]