AI_Detector / Dockerfile
mahmoudsaber0's picture
Update Dockerfile
5677c26 verified
# ===== Base Image =====
FROM python:3.10-slim
# ===== Working Directory =====
WORKDIR /app
# ===== Environment Variables =====
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
HF_HOME=/tmp/huggingface \
TRANSFORMERS_CACHE=/tmp/huggingface \
HF_DATASETS_CACHE=/tmp/huggingface \
HF_HUB_CACHE=/tmp/huggingface \
TORCH_HOME=/tmp/huggingface \
XDG_CACHE_HOME=/tmp/huggingface
# ===== System Dependencies =====
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
ffmpeg \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
# ===== Python Dependencies =====
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# ===== Cache & Permissions =====
RUN rm -rf /.cache /root/.cache /root/.huggingface && \
mkdir -p /tmp/huggingface && \
chmod -R 777 /tmp /app
# ===== Copy Project Files =====
COPY . .
# ===== Optional Performance Libraries =====
RUN pip install --no-cache-dir uvloop gunicorn
# ===== Expose App Port =====
EXPOSE 7860
# ===== Healthcheck =====
HEALTHCHECK CMD curl --fail http://localhost:7860/health || exit 1
# ===== Start App =====
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2", "--timeout-keep-alive", "30"]