Spaces:
Running
Running
File size: 1,244 Bytes
f6807a1 |
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 |
# Use a lightweight Linux base image
FROM python:3.10-slim
# Set non-interactive mode for apt-get
ENV DEBIAN_FRONTEND=noninteractive
# Install Python, pip, curl, and other dependencies
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install Ollama using curl
RUN curl -fsSL https://ollama.com/install.sh | sh
# Add a non-root user (optional for security)
RUN useradd -m -u 1000 user
USER user
# Set environment variables for Ollama
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
OLLAMA_HOST=0.0.0.0
# Set working directory
WORKDIR $HOME/app
# Install Python dependencies for your application
RUN pip3 install ollama
# Pull the required Ollama model
#RUN ollama serve & sleep 5 && ollama pull llama3.2:1b
RUN pip install gradio
# Copy your Python application
COPY app.py $HOME/app/app.py
# Expose the Ollama server port
EXPOSE 11434
EXPOSE 7860
# Set the entrypoint to bash (optional)
#ENTRYPOINT ["/bin/bash"]
ENV GRADIO_SERVER_NAME=0.0.0.0
RUN echo "Build Complete"
# Command to run your Python application
#CMD ["sh", "-c", "ollama run llama3.2:1b > ollama.log 2>&1 & python3 app.py"]
CMD ["python3", "app.py"] |