Marcin-XStudio commited on
Commit
c0dc76d
·
1 Parent(s): 1838da2

update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -20
Dockerfile CHANGED
@@ -1,33 +1,30 @@
1
- # redirige tous les caches HF vers /app/model_cache/hf_cache
2
-
3
- # Dockerfile
4
  FROM python:3.10-slim
5
  WORKDIR /app
6
 
7
- ENV HF_HOME="/app/model_cache/hf_cache"
8
- ENV TRANSFORMERS_CACHE="/app/model_cache/transformers_cache"
9
- ENV HF_HUB_CACHE="/app/model_cache/hf_hub_cache"
10
- ENV HF_DATASETS_CACHE="/app/model_cache/datasets_cache"
 
11
 
12
- # 1) Install HF tooling & runtime deps
13
- RUN pip install --no-cache-dir huggingface_hub
14
- COPY requirements.txt .
15
- RUN pip install --no-cache-dir -r requirements.txt
16
 
17
- # 2) Download model at build-time directly into model_cache
18
  RUN python - <<EOF
19
  from huggingface_hub import snapshot_download
20
- # This writes ALL repo files under /app/model_cache
21
  snapshot_download(
22
- repo_id="numind/NuExtract-1.5-tiny",
23
- local_dir="/app/model_cache"
 
24
  )
25
  EOF
26
 
27
- RUN chmod -R a+rX /app/model_cache
 
 
28
 
29
- # 3) Copy your FastAPI code
30
  COPY . .
31
-
32
- ENV PORT=7860
33
- CMD ["bash","-lc","uvicorn app:app --host 0.0.0.0 --port $PORT"]
 
 
 
 
1
  FROM python:3.10-slim
2
  WORKDIR /app
3
 
4
+ # 1) Variables pour rediriger tous les caches HF
5
+ ENV HF_HOME="/app/model_cache/hf_cache"
6
+ ENV TRANSFORMERS_CACHE="/app/model_cache/transformers_cache"
7
+ ENV HF_HUB_CACHE="/app/model_cache/hf_hub_cache"
8
+ ENV HF_DATASETS_CACHE="/app/model_cache/datasets_cache"
9
 
10
+ # 2) Installer huggingface_hub + dépendances
11
+ RUN pip install --no-cache-dir huggingface_hub \
12
+ && pip install --no-cache-dir -r requirements.txt
 
13
 
14
+ # 3) Précharger le modèle au build-time
15
  RUN python - <<EOF
16
  from huggingface_hub import snapshot_download
 
17
  snapshot_download(
18
+ repo_id="numind/NuExtract-1.5-tiny",
19
+ local_dir="/app/model_cache", # snapshot final
20
+ cache_dir="/app/model_cache/hf_cache" # cache HF
21
  )
22
  EOF
23
 
24
+ # 4) Rendre le dossier accessible à l’utilisateur
25
+ RUN chmod -R a+rX /app/model_cache \
26
+ && chown -R $(id -u):$(id -g) /app/model_cache
27
 
28
+ # 5) Copier le code et démarrer
29
  COPY . .
30
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]