-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.edge
More file actions
52 lines (40 loc) · 2.09 KB
/
Copy pathDockerfile.edge
File metadata and controls
52 lines (40 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
FROM python:3.14-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
HF_HOME=/cache/huggingface \
HF_HUB_CACHE=/cache/huggingface/hub \
TRANSFORMERS_CACHE=/cache/huggingface/hub \
HF_HUB_DISABLE_XET=1
WORKDIR /app
COPY requirements-edge.txt .
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements-edge.txt
ARG COMPRESSOR_MODEL=microsoft/llmlingua-2-bert-base-multilingual-cased-meetingbank
ARG COMPRESSOR_MODEL_REVISION=main
ARG COMPRESSOR_GIT_COMMIT=unknown
ARG COMPRESSOR_SOURCE_SHA256=unknown
ENV COMPRESSOR_MODEL=${COMPRESSOR_MODEL} \
COMPRESSOR_GIT_COMMIT=${COMPRESSOR_GIT_COMMIT} \
COMPRESSOR_SOURCE_SHA256=${COMPRESSOR_SOURCE_SHA256} \
COMPRESSOR_DEVICE=cpu \
COMPRESSOR_PRELOAD_SLOTS=
# The CPU edge needs tokenizer parity with the GPU service, but never downloads
# model weights. AutoTokenizer resolves these cached files in offline mode.
RUN mkdir -p /app/tokenizer /cache/huggingface/hub \
&& python -c "from pathlib import Path; from huggingface_hub import snapshot_download; snapshot_download('${COMPRESSOR_MODEL}', revision='${COMPRESSOR_MODEL_REVISION}', local_dir='/app/tokenizer', allow_patterns=['config.json','tokenizer.json','tokenizer_config.json','special_tokens_map.json','added_tokens.json','vocab.txt']); Path('/app/model_revision.txt').write_text('${COMPRESSOR_MODEL_REVISION}', encoding='utf-8')"
ENV HF_HUB_OFFLINE=1 \
TRANSFORMERS_OFFLINE=1 \
USE_TORCH=0 \
USE_TF=0 \
USE_FLAX=0 \
COMPRESSOR_TOKENIZER_PATH=/app/tokenizer \
EDGE_PRELOAD_TOKENIZER=true
RUN adduser --disabled-password --gecos "" appuser \
&& chown -R appuser:appuser /app /cache
COPY --chown=appuser:appuser app ./app
COPY --chown=appuser:appuser data ./data
USER appuser
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD python -c "import json, os, urllib.request; port = os.getenv('PORT', '8080'); json.load(urllib.request.urlopen(f'http://127.0.0.1:{port}/health', timeout=3))"
CMD ["sh", "-c", "exec uvicorn app.edge_main:app --host 0.0.0.0 --port ${PORT:-8080}"]