File size: 1,119 Bytes
cc67a7f
 
 
 
 
 
a2220c9
 
 
cc67a7f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a2220c9
 
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
# Use Ubuntu as the base image
FROM ubuntu:22.04

# Set the working directory in the container
WORKDIR /app

# Ensure we are running as root
USER root

# Install system dependencies and Python
RUN apt-get update && apt-get install -y \
    python3 \
    python3-pip \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Set Python3 as the default
RUN ln -s /usr/bin/python3 /usr/bin/python

# Copy the requirements file and install dependencies
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

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

# Ensure Ollama is in the system path
ENV PATH="/root/.ollama/bin:$PATH"

# Set Ollama's home directory to a writable location
ENV OLLAMA_HOME="/app/.ollama"

# Create the directory with proper permissions
RUN mkdir -p $OLLAMA_HOME && chmod -R 777 $OLLAMA_HOME

# Copy the application files
COPY . .

# Expose the FastAPI default port
EXPOSE 8000

# Start Ollama and FastAPI as root
CMD ["sh", "-c", "export OLLAMA_HOME=/app/.ollama && ollama serve & sleep 5 && ollama pull llama3 && uvicorn main:app --host 0.0.0.0 --port 8000"]