-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.gpu
More file actions
40 lines (30 loc) · 1.54 KB
/
Copy pathDockerfile.gpu
File metadata and controls
40 lines (30 loc) · 1.54 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
ARG GPU_BASE_IMAGE=us-docker.pkg.dev/deeplearning-platform-release/gcr.io/pytorch-cu124.2-4.py310
FROM ${GPU_BASE_IMAGE}
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
HF_HOME=/cache/huggingface \
HF_HUB_CACHE=/cache/huggingface/hub \
TRANSFORMERS_CACHE=/cache/huggingface/hub \
PIP_NO_CACHE_DIR=1
WORKDIR /app
COPY requirements.txt .
RUN python -m pip install --upgrade pip \
&& grep -vE '^torch([=<>!~]|$)' requirements.txt > /tmp/requirements-no-torch.txt \
&& python -m pip install -r /tmp/requirements-no-torch.txt
ARG COMPRESSOR_MODEL=microsoft/llmlingua-2-bert-base-multilingual-cased-meetingbank
ENV COMPRESSOR_MODEL=${COMPRESSOR_MODEL}
RUN mkdir -p /cache/huggingface/hub \
&& python -c "import os; from huggingface_hub import snapshot_download; snapshot_download(os.environ['COMPRESSOR_MODEL'], cache_dir=os.environ['HF_HUB_CACHE'])"
ENV HF_HUB_OFFLINE=1 \
TRANSFORMERS_OFFLINE=1
RUN groupadd --system appuser \
&& useradd --system --gid appuser --home-dir /app --shell /usr/sbin/nologin appuser \
&& chown -R appuser:appuser /app /cache
COPY --chown=appuser:appuser app ./app
COPY --chown=appuser:appuser data ./data
COPY --chown=appuser:appuser models ./models
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}"]