Spaces:
Sleeping
Sleeping
# The python builder image, used to build the virtual environment | |
FROM python:3.11-slim-buster | |
# Install system dependencies | |
RUN apt-get update && apt-get install -y --no-install-recommends git && \ | |
rm -rf /var/lib/apt/lists/* | |
# Create a user to run the app | |
RUN useradd -m -u 1000 user | |
# Switch to user and set environment variables | |
USER user | |
ENV HOME=/home/user \ | |
PATH="/home/user/.local/bin:$PATH" \ | |
VIRTUAL_ENV=/home/user/venv \ | |
LISTEN_PORT=7860 \ | |
HOST=0.0.0.0 | |
# Set the working directory in the container | |
WORKDIR $HOME | |
# Create a virtual environment to isolate our package dependencies locally | |
RUN python -m venv $VIRTUAL_ENV | |
ENV PATH="$VIRTUAL_ENV/bin:$PATH" | |
# Copy necessary files to container directory | |
COPY --chown=user ./app ./app/app | |
COPY --chown=user ./chroma ./chroma | |
COPY --chown=user ./sparse_index ./sparse_index | |
COPY --chown=user ./.env ./app/.env | |
COPY --chown=user ./app/chainlit.md ./app/chainlit.md | |
COPY --chown=user ./app/.chainlit ./app/.chainlit | |
COPY --chown=user ./app/public ./app/public | |
COPY --chown=user ./input_data/Templates/template_files ./input_data/Templates/template_files | |
COPY --chown=user ./requirements_Docker.txt ./app/requirements_Docker.txt | |
COPY --chown=user ./init_embedding_model.py ./app/init_embedding_model.py | |
WORKDIR $HOME/app | |
# Install Python dependencies | |
RUN pip install --upgrade pip && \ | |
pip install -r ./requirements_Docker.txt | |
# Run the script to initialize and cache the fine-tuned embedding model | |
RUN python ./init_embedding_model.py | |
# Expose the port the app runs on | |
EXPOSE $LISTEN_PORT | |
# Run the chainlit app | |
CMD ["chainlit", "run", "app/app.py", "--host", "0.0.0.0", "--port", "7860"] |