File size: 1,399 Bytes
e20bd72 0d56c08 |
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 |
# Use the official Python 3.11 slim image
FROM python:3.11-slim
# Install curl for keep-alive script and clean up
RUN apt-get update && \
apt-get install -y curl && \
rm -rf /var/lib/apt/lists/*
# Set the working directory inside the container
WORKDIR /app
# Create all required directories with proper permissions upfront
RUN mkdir -p /app/generated_outputs && \
mkdir -p /app/generated_charts && \
mkdir -p /app/cache && \
chmod -R 777 /app/generated_outputs && \
chmod -R 777 /app/generated_charts && \
chmod -R 777 /app/cache
# Create log files with proper permissions
RUN touch /app/pandasai.log && \
touch /app/api_key_rotation.log && \
chmod 666 /app/pandasai.log && \
chmod 666 /app/api_key_rotation.log
# Set environment variables
ENV MPLCONFIGDIR=/app/cache
# Copy the requirements file first
COPY requirements.txt .
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code
COPY . .
# Ensure the user has write permissions to all directories
RUN chown -R 1000:1000 /app && \
chmod -R 777 /app
# Expose port 7860 (required by Hugging Face Spaces)
EXPOSE 7860
# Keep-alive command (pings every 5 minutes) + start Uvicorn
CMD bash -c "while true; do curl -s https://soumik555-fastapi.hf.space/ping >/dev/null && sleep 300; done & uvicorn controller:app --host 0.0.0.0 --port 7860" |