File size: 2,417 Bytes
e321159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

# # WORKS
# # Use the official slim Python 3.9 image
# FROM python:3.9-slim

# # Install necessary build dependencies
# RUN apt-get update && apt-get install -y build-essential python3-dev libffi-dev && apt-get clean

# # Create a new user with a specific UID
# RUN useradd -m -u 1000 user

# # Set environment variables
# ENV HOME=/home/user \
#     PATH=/usr/local/bin:$PATH

# # Set the working directory
# WORKDIR $HOME/app

# # Copy only the requirements file first to leverage Docker's layer caching
# COPY --chown=user requirements.txt $HOME/app/requirements.txt

# # Install dependencies
# RUN pip install --no-cache-dir --upgrade pip && \
#     pip install --no-cache-dir protobuf==3.20.0 && \
#     pip install --no-cache-dir -r requirements.txt

# # Install chainlit separately
# RUN pip install --no-cache-dir chainlit

# # Verify chainlit installation and check global binaries
# RUN ls /usr/local/bin && pip show chainlit

# # Copy the rest of the application files into the container
# COPY --chown=user . $HOME/app

# # Expose the port that Chainlit will run on
# EXPOSE 7860

# # Run Chainlit with the specified command
# CMD ["chainlit", "run", "app.py", "--port", "7860"]


# Use the official slim Python 3.9 image
FROM python:3.9-slim

# Install necessary build dependencies
RUN apt-get update && apt-get install -y build-essential python3-dev libffi-dev && apt-get clean

# Create a new user with a specific UID
RUN useradd -m -u 1000 user

# Set environment variables
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Set the working directory
WORKDIR $HOME/app

# Copy only the requirements file first to leverage Docker's layer caching
COPY --chown=user requirements.txt $HOME/app/requirements.txt

# Print requirements.txt content for debugging
RUN cat requirements.txt

# Install dependencies
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# Install chainlit explicitly and verify its installation
RUN pip install --no-cache-dir chainlit==0.7.700 && \
    which chainlit && \
    chainlit --version

# Verify all installations
RUN pip list

# Copy the rest of the application files into the container
COPY --chown=user . $HOME/app

# Expose the port that Chainlit will run on
EXPOSE 7860

# Switch to the non-root user
USER user

# Run Chainlit with the specified command
CMD ["chainlit", "run", "app.py", "--port", "7860"]