FROM crpi-4b5m1drruxllpt5o.cn-hangzhou.personal.cr.aliyuncs.com/mt-cloud/python:3.12-slim

ENV PIP_NO_CACHE_DIR=1

ARG AREA=china

COPY . /app

WORKDIR /app

RUN set -ex \
    && mkdir -p .pip  \
    && if [ 'china' = "$AREA" ] ; then \
      pip3 install -i https://mirrors.aliyun.com/pypi/simple --no-cache-dir -r requirements.txt; \
    else \
      pip3 install -r --no-cache-dir requirements.txt; \
    fi

# 设置环境变量（关键！确保 Django 输出直接打印到控制台）
ENV PYTHONUNBUFFERED=1
ENV DJANGO_SETTINGS_MODULE=smart_inspect.settings
RUN mkdir -p /data/pic /data/file

EXPOSE 8000

CMD ["python3", "/app/manage.py", "runserver", "0.0.0.0:8000"]

# FROM python:3.11-slim

# ENV PYTHONDONTWRITEBYTECODE=1
# ENV PYTHONUNBUFFERED=1

# WORKDIR /app

# # system deps
# RUN apt-get update && apt-get install -y --no-install-recommends build-essential gcc && rm -rf /var/lib/apt/lists/*

# # copy and install python deps
# COPY requirements.txt ./
# RUN pip install --no-cache-dir -r requirements.txt gunicorn

# # copy project
# COPY . /app

# # create media folders
# RUN mkdir -p /data/pic /data/file

# entrypoint will run migrations then start the server
# COPY entrypoint.sh /entrypoint.sh
# RUN chmod +x /entrypoint.sh

# ENTRYPOINT ["/entrypoint.sh"]
# CMD ["gunicorn", "smart_inspect.wsgi:application", "--bind", "0.0.0.0:8000"]


