-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
35 lines (25 loc) · 1.27 KB
/
Copy pathDockerfile
File metadata and controls
35 lines (25 loc) · 1.27 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
FROM python:3.14-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
HF_HOME=/cache/huggingface \
HF_HUB_CACHE=/cache/huggingface \
TRANSFORMERS_CACHE=/cache/huggingface
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu "torch==2.12.1+cpu" \
&& pip install --no-cache-dir -r requirements.txt
ARG COMPRESSOR_MODEL=microsoft/llmlingua-2-bert-base-multilingual-cased-meetingbank
ENV COMPRESSOR_MODEL=${COMPRESSOR_MODEL}
RUN python -c "import os; from huggingface_hub import snapshot_download; snapshot_download(os.environ['COMPRESSOR_MODEL'], cache_dir=os.environ['HF_HOME'])"
ENV HF_HUB_OFFLINE=1 \
TRANSFORMERS_OFFLINE=1
RUN adduser --disabled-password --gecos "" appuser \
&& mkdir -p /cache/huggingface \
&& chown -R appuser:appuser /app /cache
COPY --chown=appuser:appuser app ./app
USER appuser
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --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.main:app --host 0.0.0.0 --port ${PORT:-8080}"]