FROM python:3.9-slim WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ libpq-dev \ && rm -rf /var/lib/apt/lists/* # Install Python packages COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY . . # Create necessary files with proper permissions RUN touch database.csv chat_history.csv && \ chmod 666 database.csv chat_history.csv # Create a non-root user RUN useradd -m -u 1000 user # Give full permissions to the app directory RUN chmod -R 777 /app EXPOSE 7860 CMD ["python", "app.py"]