File size: 1,640 Bytes
7ccd501
 
 
f427afc
8775295
585bc48
8775295
 
 
 
585bc48
 
f427afc
 
 
 
 
585bc48
 
f427afc
585bc48
 
f427afc
8775295
7ccd501
 
585bc48
 
 
 
7ccd501
8775295
585bc48
 
 
 
7ccd501
8775295
 
 
7ccd501
 
 
585bc48
7ccd501
8775295
7ccd501
 
 
8775295
7ccd501
 
8775295
 
7ccd501
8775295
7ccd501
 
8775295
 
 
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
# Use the official Python 3.11 slim image
FROM python:3.11-slim

# Install system dependencies required for Math/Data libraries + WeasyPrint
# libgomp1 is CRITICAL for scikit-learn & numpy parallelization to prevent segfaults
RUN apt-get update && apt-get install -y --no-install-recommends \
    curl \
    gcc \
    g++ \
    libgomp1 \
    libpango-1.0-0 \
    libpangoft2-1.0-0 \
    libpangocairo-1.0-0 \
    libgdk-pixbuf2.0-0 \
    libffi-dev \
    libcairo2 \
    libcairo2-dev \
    libjpeg62-turbo-dev \
    libopenjp2-7-dev \
    libssl-dev \
    fonts-dejavu \
    fonts-liberation \
    fontconfig \
    && rm -rf /var/lib/apt/lists/*

# Set the working directory inside the container
RUN mkdir -p /app/output \
    /app/chat_pdfs \
    /app/generated_charts \
    /app/cache

# Create required directories with permissions
RUN chmod -R 777 /app/output \
    /app/chat_pdfs \
    /app/generated_charts \
    /app/cache

# Create log files
RUN touch /app/pandasai.log /app/api_key_rotation.log && \
    chmod 666 /app/pandasai.log /app/api_key_rotation.log

# Set environment variables
ENV MPLCONFIGDIR=/app/cache
ENV PYTHONUNBUFFERED=1

# Copy requirements and install
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY . .

# Ensure permissions
RUN chown -R 1000:1000 /app && chmod -R 777 /app

# Expose port
EXPOSE 7860

# CMD: Run the python script directly.
# This ensures the 'if __name__ == "__main__":' block in your code actually runs.
CMD bash -c "while true; do curl -s https://code-api-executor.hf.space/ping >/dev/null && sleep 300; done & python controller.py"