FROM python:3.12-slim # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 ENV PYTHONPATH=/home/user/app # Create and set working directory WORKDIR /home/user/app # Install system dependencies RUN apt-get update && apt-get install -y \ libpq-dev \ gcc \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy all project files COPY . . # Collect static files, migrate, and start gunicorn # Note: We bind to 0.0.0.0:7860 as required by Hugging Face CMD python manage.py collectstatic --noinput && \ python manage.py migrate && \ gunicorn wsgi:application --bind 0.0.0.0:7860