FROM python:3.10-slim RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* RUN pip install --no-cache-dir \ fastapi==0.110.3 \ uvicorn==0.30.1 \ rembg==2.0.57 \ pillow==10.3.0 \ python-multipart==0.0.9 RUN pip install gradio_client # Matikan JIT Numba (hindari error caching di container) ENV NUMBA_DISABLE_JIT=1 # Pastikan cache model ke folder yang writable ENV HOME=/root ENV U2NET_HOME=/root/.u2net ENV POOCH_HOME=/root/.cache/pooch RUN mkdir -p /root/.u2net /root/.cache/pooch && chmod -R 777 /root/.u2net /root/.cache WORKDIR /app COPY app.py /app/app.py # Prefetch model U²Net (unduh saat build) RUN python - <<'PY' from rembg.session_factory import new_session new_session('u2net') print('Model U2Net terunduh.') PY EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]