File size: 2,481 Bytes
20a070f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46bec16
 
 
 
 
 
 
 
 
 
 
 
20a070f
 
b5edc51
20a070f
 
b5edc51
 
 
20a070f
 
 
 
9403589
20a070f
 
9403589
20a070f
 
9403589
 
20a070f
46bec16
20a070f
 
 
 
 
 
 
 
b5edc51
 
 
 
 
20a070f
 
 
 
 
12989ae
20a070f
b5edc51
3d5a52f
12989ae
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
FROM nvidia/cuda:11.7.1-cudnn8-runtime-ubuntu20.04

# Use Python 3.11 for better Python perf
# Update the package lists and install necessary dependencies
RUN apt-get update && apt-get install -y \
    software-properties-common \
    && add-apt-repository -y ppa:deadsnakes/ppa \
    && apt-get update \
    && apt-get install -y python3.11 python3.11-dev

# Set Python 3.11 as the default version (for python3)
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1

# Download get-pip.py script
RUN apt install curl -y
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

# Install pip for Python 3.11
RUN python3 get-pip.py

# Verify Python and pip versions
RUN python3 --version && pip3.11 --version

# Set pip3.11 as the default pip command
RUN update-alternatives --install /usr/bin/pip3 pip3 /usr/local/lib/python3.11/dist-packages/pip 1

ENV PYTHONUNBUFFERED=1

# Install necessary dependencies
# RUN apt-get update && \
#     apt-get install -y python3-pip

### Set up user with permissions
# 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. /app is mounted to the container with -v, 
# but we want to have the right cwd for uvicorn command below
RUN mkdir $HOME/app
# WORKDIR /app

# Copy the current directory contents into the container at $HOME/app setting the owner to the user
COPY --chown=user . $HOME/app

# # Copy the app code and requirements filed
# COPY . /app
# COPY requirements.txt .
# WORKDIR $PYSETUP_PATH
COPY ./requirements.txt  $HOME/app


COPY ./utils $HOME/app/utils
# COPY ./static /app/static
# COPY ./templates /app/templates
COPY ./app.py $HOME/app/app.py
COPY ./download.py $HOME/app/download.py

WORKDIR $HOME/app


# Install the app dependencies
# RUN pip3 install -r requirements.txt

RUN --mount=type=cache,target=/root/.cache/pip \
        pip3 install -r requirements.txt

### Update permissions for the app
USER root
RUN chmod 777 ~/app/*
USER user

# Expose the FastAPI port
EXPOSE 7860

# Start the FastAPI app using Uvicorn web server
# CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "14000", "--limit-concurrency", "1000"]
# RUN python3 download.py

# RUN chmod 755 models

CMD ["python3", "app.py", "--host=0.0.0.0", "--port=7860", "--model_path=BAAI/bge-small-en-v1.5", "--num_workers=2"]