test / Dockerfile
qwgyuz86's picture
Update Dockerfile
4a7287f verified
# Define the base image
FROM python:3.9
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH="/home/user/.local/bin:$PATH"
# Create app directory
WORKDIR $HOME/app
# Try and run pip command after setting the user with `USER user` to avoid permission issues with Python
RUN pip install --no-cache-dir --upgrade pip
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
COPY --chown=user . $HOME/app
# Set environment variables
ENV EMBED_DEVICE_CHOICE="cpu" \
PYTHONUNBUFFERED=1
# Install system dependencies
RUN apt-get update && \
apt-get install -y curl
# apt-get clean && rm -rf /var/lib/apt/lists/*
# Install Ollama
RUN curl -fsSL https://ollama.com/install.sh | sh
# Install Python dependencies
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt
# Expose port for the Gradio app
EXPOSE 7860
ENV GRADIO_SERVER_NAME="0.0.0.0"
# Pull the Llama model using Ollama
RUN ollama serve & sleep 10 && ollama run wangshenzhi/llama3-8b-chinese-chat-ollama-q4
# Start the Ollama server and the app
CMD ollama serve & python chatbot_app.py