File size: 1,715 Bytes
579ab0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# 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 ./embedding_model ./embedding_model
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 ./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_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"]