# =========================
# Base Image
# =========================
FROM python:3.12-slim

# =========================
# Environment Variables
# =========================
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# =========================
# System Dependencies
# =========================
RUN apt-get update && apt-get install -y \
    build-essential \
    libpq-dev \
    curl \
    && rm -rf /var/lib/apt/lists/*

# =========================
# Working Directory
# =========================
WORKDIR /app

# =========================
# Python Dependencies
# =========================
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# =========================
# Copy Project Files
# =========================
COPY . .

# =========================
# Collect Static Files
# =========================
RUN python manage.py collectstatic --noinput

# =========================
# Expose Application Port
# =========================
EXPOSE 8000

# =========================
# Run Application
# =========================
# =========================
# Run Application
# =========================
CMD ["python", "-m", "gunicorn", "core.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "3", "--timeout", "120"]