Spaces:
Running
Running
Download Dockerfile from Rodion111/translator: direct link, hf CLI and curl.
- Browser
- Download file 947 Bytes
-
https://huggingface.co/spaces/Rodion111/translator/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/Rodion111/translator/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/Rodion111/translator/resolve/main/Dockerfile
947 Bytes
| # Stage 1: fetch Helsinki-NLP opus-mt he-ru / ru-he from HF Hub and convert to CTranslate2 int8 (~80 MB each) | |
| FROM python:3.12-slim AS mt | |
| RUN pip install --no-cache-dir ctranslate2 sentencepiece transformers \ | |
| torch --index-url https://download.pytorch.org/whl/cpu --extra-index-url https://pypi.org/simple | |
| RUN for p in he-ru ru-he; do \ | |
| ct2-transformers-converter --model Helsinki-NLP/opus-mt-$p --output_dir /models/opus-$p \ | |
| --quantization int8 --copy_files source.spm target.spm --low_cpu_mem_usage; \ | |
| done && rm -rf /root/.cache | |
| # Stage 2: runtime (no torch/transformers) | |
| FROM python:3.12-slim | |
| RUN pip install --no-cache-dir aiohttp==3.* ctranslate2 sentencepiece | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| WORKDIR /app | |
| COPY --from=mt --chown=user /models ./models | |
| COPY --chown=user server.py opus_mt.py ./ | |
| COPY --chown=user public ./public | |
| ENV HOST=0.0.0.0 PORT=7860 OPUS_THREADS=2 | |
| EXPOSE 7860 | |
| CMD ["python3", "server.py"] | |