File size: 896 Bytes
8f09318
 
b25dcfb
 
 
 
 
8f09318
b25dcfb
 
 
 
8f09318
 
 
 
b25dcfb
8f09318
 
b25dcfb
 
8f09318
 
b25dcfb
 
 
 
8f09318
 
 
 
 
 
 
 
 
 
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
FROM python:3.11-slim

# Create non-root user for security
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

WORKDIR $HOME/app

# Install system dependencies as root, then switch back to user
USER root
RUN apt-get update && apt-get install -y \
    gcc \
    g++ \
    && rm -rf /var/lib/apt/lists/*
USER user

# Copy requirements and install Python dependencies
COPY --chown=user requirements.txt .
RUN pip install --user --no-cache-dir -r requirements.txt

# Copy application code
COPY --chown=user . .

# Create necessary directories with proper permissions
RUN mkdir -p $HOME/app/.files $HOME/app/.chainlit

# Expose port for Hugging Face Spaces
EXPOSE 7860

# Set environment variables for Chainlit
ENV CHAINLIT_HOST=0.0.0.0
ENV CHAINLIT_PORT=7860

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