Mystyc commited on
Commit
475e76d
·
verified ·
1 Parent(s): 6edda7f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +5 -9
Dockerfile CHANGED
@@ -1,9 +1,7 @@
1
  FROM python:3.10-slim
2
 
3
- # tools minimal
4
  RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
5
 
6
- # lib python
7
  RUN pip install --no-cache-dir \
8
  fastapi==0.110.3 \
9
  uvicorn==0.30.1 \
@@ -11,23 +9,21 @@ RUN pip install --no-cache-dir \
11
  pillow==10.3.0 \
12
  python-multipart==0.0.9
13
 
14
- # ---- FIX: numba & cache lokasi model ----
15
  ENV NUMBA_DISABLE_JIT=1
 
 
16
  ENV HOME=/root
17
  ENV U2NET_HOME=/root/.u2net
18
  ENV POOCH_HOME=/root/.cache/pooch
19
-
20
- # siapkan folder cache yg writable
21
  RUN mkdir -p /root/.u2net /root/.cache/pooch && chmod -R 777 /root/.u2net /root/.cache
22
 
23
  WORKDIR /app
24
  COPY app.py /app/app.py
25
 
26
- # (OPSI KUAT DISARANKAN) Prefetch model saat build agar request pertama cepat
27
- # ini akan otomatis download model U²Net ke U2NET_HOME/POOCH_HOME
28
  RUN python - <<'PY'
29
- from rembg.session_base import new_session
30
- # model default 'u2net' cukup untuk foto produk
31
  new_session('u2net')
32
  print('Model U2Net terunduh.')
33
  PY
 
1
  FROM python:3.10-slim
2
 
 
3
  RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
4
 
 
5
  RUN pip install --no-cache-dir \
6
  fastapi==0.110.3 \
7
  uvicorn==0.30.1 \
 
9
  pillow==10.3.0 \
10
  python-multipart==0.0.9
11
 
12
+ # Matikan JIT Numba (hindari error caching di container)
13
  ENV NUMBA_DISABLE_JIT=1
14
+
15
+ # Pastikan cache model ke folder yang writable
16
  ENV HOME=/root
17
  ENV U2NET_HOME=/root/.u2net
18
  ENV POOCH_HOME=/root/.cache/pooch
 
 
19
  RUN mkdir -p /root/.u2net /root/.cache/pooch && chmod -R 777 /root/.u2net /root/.cache
20
 
21
  WORKDIR /app
22
  COPY app.py /app/app.py
23
 
24
+ # Prefetch model U²Net (unduh saat build)
 
25
  RUN python - <<'PY'
26
+ from rembg.session_factory import new_session
 
27
  new_session('u2net')
28
  print('Model U2Net terunduh.')
29
  PY