File size: 1,250 Bytes
bada07a
 
0348a43
 
bada07a
 
 
 
 
 
 
 
7fd0fd5
bada07a
7fd0fd5
 
bada07a
0348a43
 
 
 
 
 
 
 
 
 
 
 
bada07a
 
0348a43
 
 
 
 
 
 
7fd0fd5
0348a43
 
bada07a
7e781a9
bada07a
 
4079cf5
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
FROM python:3.11-slim

# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user

# Install system dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    build-essential \
    python3-dev \
    && rm -rf /var/lib/apt/lists/*

# Create virtual environment and set ownership
ENV VIRTUAL_ENV=/opt/venv
RUN python3 -m venv $VIRTUAL_ENV && \
    chown -R user:user $VIRTUAL_ENV

# Switch to the "user" user
USER user

# Set home and PATH
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$VIRTUAL_ENV/bin:$PATH

# Set the working directory to the user's home directory
WORKDIR $HOME/app

# Copy requirements first (with correct ownership)
COPY --chown=user requirements.txt $HOME/app/requirements.txt

# Install dependencies in virtual environment
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir --upgrade -r requirements.txt && \
    pip install -qU chainlit

# Copy the rest of the application with correct ownership
COPY --chown=user . $HOME/app

# Create content directory for assets
RUN mkdir -p content

# Expose the default Chainlit port
EXPOSE 7860

# Command to run the application
CMD ["chainlit", "run", "app.py", "--port", "7860", "--host", "0.0.0.0"]