arindae commited on
Commit
be164df
·
1 Parent(s): 6fb5195

corrected dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +8 -32
Dockerfile CHANGED
@@ -1,38 +1,14 @@
1
- # FastAPI model-serving container for Hugging Face Docker Spaces.
2
- # The Django project owns the user-facing frontend.
3
 
4
- # ---- Stage 1: convert NLLB to CTranslate2 int8 (needs torch, build-only) ----
5
- FROM python:3.11-slim AS model
6
- WORKDIR /m
7
- COPY backend/requirements.txt backend/requirements-convert.txt ./
8
  RUN pip install --no-cache-dir -r requirements.txt \
9
- && pip install --no-cache-dir -r requirements-convert.txt --extra-index-url https://download.pytorch.org/whl/cpu
10
- # CTranslate2 wheels ship a .so that requests an executable stack, which hardened
11
- # container runtimes (incl. HuggingFace Spaces) refuse. Clear the flag.
12
- RUN apt-get update && apt-get install -y --no-install-recommends patchelf \
13
- && find /usr/local/lib/python3.11/site-packages -name '*.so*' -path '*ctranslate2*' -exec patchelf --clear-execstack {} + \
14
- && apt-get purge -y patchelf && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*
15
- # RUN python convert_model.py # writes ./models/nllb-200-distilled-600M-int8
16
- # RUN HF_MODEL=facebook/nllb-200-distilled-1.3B \
17
- # CT2_MODEL_DIR=models/nllb-200-distilled-1.3B-int8 \
18
- # python convert_model.py
19
- # MADLAD-400: fetch the pre-converted CTranslate2 int8 (model + tokenizer, ~3 GB)
20
- RUN python -c "from huggingface_hub import snapshot_download; snapshot_download('Nextcloud-AI/madlad400-3b-mt-ct2-int8', local_dir='models/madlad400-3b-mt-int8')"
21
 
22
- # ---- Stage 2: lean API runtime (no torch) ----
23
- FROM python:3.11-slim AS runtime
24
- WORKDIR /app
25
- ENV HF_HUB_DISABLE_SYMLINKS_WARNING=1 \
26
- MADLAD_HF_MODEL=/app/models/madlad400-3b-mt-int8
27
- COPY backend/requirements.txt ./
28
- RUN pip install --no-cache-dir -r requirements.txt
29
- # Same execstack fix for the runtime inference library.
30
- RUN apt-get update && apt-get install -y --no-install-recommends patchelf \
31
- && find /usr/local/lib/python3.11/site-packages -name '*.so*' -path '*ctranslate2*' -exec patchelf --clear-execstack {} + \
32
- && apt-get purge -y patchelf && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*
33
- COPY backend/ ./
34
- COPY --from=model /m/models ./models
35
- EXPOSE 7860
36
  COPY entrypoint.sh .
37
  RUN chmod +x entrypoint.sh
 
 
38
  CMD ["./entrypoint.sh"]
 
1
+ FROM python:3.11-slim
2
+ WORKDIR /app
3
 
4
+ COPY requirements.txt requirements-convert.txt ./
 
 
 
5
  RUN pip install --no-cache-dir -r requirements.txt \
6
+ && pip install --no-cache-dir -r requirements-convert.txt --extra-index-url https://download.pytorch.org/whl/cpu
7
+
8
+ COPY . .
 
 
 
 
 
 
 
 
 
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  COPY entrypoint.sh .
11
  RUN chmod +x entrypoint.sh
12
+
13
+ EXPOSE 7860
14
  CMD ["./entrypoint.sh"]