File size: 997 Bytes
37d460f
 
 
 
 
 
 
 
 
 
 
ce67515
 
 
37d460f
 
 
 
fbaa829
 
 
 
37d460f
 
 
fbaa829
 
ce67515
 
 
 
37d460f
 
 
 
ce67515
 
 
 
 
fa43227
37d460f
c928d10
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
FROM python:3.10-slim

WORKDIR /code

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    software-properties-common \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user
RUN useradd -m -u 1000 chainlit_user

# Copy requirements first for better caching
COPY requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Create necessary directories
RUN mkdir -p /code/.files && \
    mkdir -p /code/.chainlit

# Copy the rest of the application
COPY . /code/

# Set permissions
RUN chown -R chainlit_user:chainlit_user /code && \
    chmod -R 755 /code && \
    chmod -R 777 /code/.files && \
    chmod -R 777 /code/.chainlit

# Set environment variables
ENV HOST=0.0.0.0
ENV PORT=7860
ENV PYTHONPATH=/code
ENV OPENAI_API_KEY=${OPENAI_API_KEY}
ENV PYTHONUNBUFFERED=1

# Switch to non-root user
USER chainlit_user

# Command to run the application
CMD chainlit run app.py --host $HOST --port $PORT