# Use the official Python image from the Docker Hub FROM python:3.9 # Install curl RUN apt-get update && apt-get install -y curl RUN curl -fsSL https://ollama.com/install.sh | sh # # Create a new user with a home directory and set the user ID RUN useradd -m -u 1000 user # # Switch to the new user USER user # # Set the PATH environment variable to include the user's local bin directory ENV PATH="/home/user/.local/bin:$PATH" # # Set the working directory to /app WORKDIR /app # # Copy the requirements.txt file and install the dependencies COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # # Copy the rest of the application code to the /app directory COPY --chown=user . /app # Install Ollama # Create the directory and give appropriate permissions # RUN mkdir -p /.app && chmod 777 /.app # WORKDIR /.app # Copy the entry point script COPY entry.sh /app/entry.sh RUN chmod +x /app/entry.sh ENTRYPOINT ["/entry.sh"] CMD ["ollama", "serve"] # Set the command to run the application # CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"] EXPOSE 7860