# Dockerfile

# 1. Base Image: استفاده از ایمیج رسمی پایتون نسخه 3.11
FROM python:3.11-slim-buster

# 2. Set Environment Variables:
# - prevents python creating .pyc files
ENV PYTHONDONTWRITEBYTECODE 1
# - ensures python output is sent straight to the terminal without buffering
ENV PYTHONUNBUFFERED 1

# 3. Create & Set Working Directory:
WORKDIR /app

# 4. Install dependencies:
# - Upgrade pip
RUN pip install --upgrade pip
# - Copy requirements file
COPY requirements.txt /app/
# - Install requirements
RUN pip install -r requirements.txt

# 5. Copy project code into the container:
COPY . /app/

RUN python manage.py collectstatic --noinput
# 6. Expose port 8000:
# (پورت پیش‌فرض جنگو و Gunicorn)
EXPOSE 8000

# 7. Run Gunicorn:
# دستور پیش‌فرض برای اجرای سرور وقتی کانتینر بالا میاد
# 'project_name.wsgi:application' رو با مسیر فایل wsgi خودت جایگزین کن
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "project_name.wsgi:application"]