matriv-rag-demo / Dockerfile
AdrienB134's picture
Update Dockerfile
dd14df2 verified
# Use Python 3.10 as base image
FROM python:3.10-slim
# Install system dependencies and uv
RUN apt-get update && apt-get install -y \
poppler-utils \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& curl -LsSf https://astral.sh/uv/install.sh | sh \
&& echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc \
&& . ~/.bashrc
# Copy requirements first to leverage Docker cache
COPY pyproject.toml .
# Install Python dependencies using uv
RUN . ~/.bashrc && uv pip install -r pyproject.toml --system && uv pip install llama-index-readers-file --system
# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user
# Switch to the "user" user
USER user
# Set home to the user's home directory
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Set the working directory to the user's home directory
WORKDIR $HOME/app
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
COPY --chown=user . $HOME/app
# Create directories for uploads and embeddings if they don't exist
RUN mkdir -p uploads embeddings
# Expose the port the app runs on
EXPOSE 7860
# Change to rag_demo directory and run the app
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]