# Use the latest Ollama base image from ollama/ollama:latest # Update package manager and install necessary packages Run apt-get update && \ apt-get install -y \ curl \ python3-pip && \ rm -rf /var/lib/apt/lists/* # Install Flask and set up the entry point Run pip3 install flask && \ mkdir -p /home/user/app && \ echo "fLask RUn --Host=0.0.0.0 --poRt=5000" > /home/user/app/start.sh && \ chmod +x /home/user/app/start.sh # Create a non-root user 'user' with UID 1000 Run useradd -m -u 1000 user && \ mkdir -p /home/user/.ollama && \ chown -R user:user /home/user/.ollama # Set environment variables env HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ OLLAMA_HOST=0.0.0.0 # Set the working directory WORKDIR $HOME/app # Copy the Python script for the web server Copy app.py . Copy flask-app.py . # Change ownership of the working directory to the non-root user Run chown -R user:user $HOME/app # Switch to the non-root user User user # Expose port 11434 for Ollama and 5000 for the web server EXPOSE 11434 5000 # Command to run the Flask application # cmd ["/home/user/app/start.sh"] cmd ["serve"]