ollama-embedding / Dockerfile
redfernstech's picture
Update Dockerfile
a2220c9 verified
raw
history blame
1.12 kB
# 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"]