Soumik555 commited on
Commit
e20bd72
·
1 Parent(s): d10031d
Files changed (1) hide show
  1. Dockerfile +46 -0
Dockerfile ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use the official Python 3.11 slim image
2
+ FROM python:3.11-slim
3
+
4
+ # Install curl for keep-alive script and clean up
5
+ RUN apt-get update && \
6
+ apt-get install -y curl && \
7
+ rm -rf /var/lib/apt/lists/*
8
+
9
+ # Set the working directory inside the container
10
+ WORKDIR /app
11
+
12
+ # Create all required directories with proper permissions upfront
13
+ RUN mkdir -p /app/generated_outputs && \
14
+ mkdir -p /app/generated_charts && \
15
+ mkdir -p /app/cache && \
16
+ chmod -R 777 /app/generated_outputs && \
17
+ chmod -R 777 /app/generated_charts && \
18
+ chmod -R 777 /app/cache
19
+
20
+ # Create log files with proper permissions
21
+ RUN touch /app/pandasai.log && \
22
+ touch /app/api_key_rotation.log && \
23
+ chmod 666 /app/pandasai.log && \
24
+ chmod 666 /app/api_key_rotation.log
25
+
26
+ # Set environment variables
27
+ ENV MPLCONFIGDIR=/app/cache
28
+
29
+ # Copy the requirements file first
30
+ COPY requirements.txt .
31
+
32
+ # Install dependencies
33
+ RUN pip install --no-cache-dir -r requirements.txt
34
+
35
+ # Copy the rest of the application code
36
+ COPY . .
37
+
38
+ # Ensure the user has write permissions to all directories
39
+ RUN chown -R 1000:1000 /app && \
40
+ chmod -R 777 /app
41
+
42
+ # Expose port 7860 (required by Hugging Face Spaces)
43
+ EXPOSE 7860
44
+
45
+ # Keep-alive command (pings every 5 minutes) + start Uvicorn
46
+ CMD bash -c "while true; do curl -s http://localhost:7860/ping >/dev/null && sleep 300; done & uvicorn controller:app --host 0.0.0.0 --port 7860"