-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (38 loc) · 1.59 KB
/
Copy pathDockerfile
File metadata and controls
53 lines (38 loc) · 1.59 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
53
ARG PARENT_IMAGE=kernai/refinery-parent-images:v3.1.0-torch-cpu
ARG DHI_PYTHON_BUILD=dhi.io/python:3.11-debian12-dev
FROM ${PARENT_IMAGE} AS venv-source
FROM ${DHI_PYTHON_BUILD} AS builder
ENV VENV_PATH=/opt/venv
ENV PATH="${VENV_PATH}/bin:${PATH}"
ENV HF_HOME=/tmp/huggingface
ENV TRANSFORMERS_CACHE=/tmp/huggingface/transformers
ENV SENTENCE_TRANSFORMERS_HOME=/tmp/sentence-transformers
ENV TOKENIZERS_PARALLELISM=false
ENV OMP_NUM_THREADS=1
ENV MKL_NUM_THREADS=1
ENV OPENBLAS_NUM_THREADS=1
WORKDIR /program
COPY --from=venv-source ${VENV_PATH} ${VENV_PATH}
COPY requirements.txt .
RUN pip3 install --no-cache-dir -r requirements.txt
RUN mkdir -p /inference "${HF_HOME}" "${TRANSFORMERS_CACHE}" "${SENTENCE_TRANSFORMERS_HOME}" && \
chown -R 65532:65532 /inference "${HF_HOME}" "${SENTENCE_TRANSFORMERS_HOME}"
COPY . .
FROM ${PARENT_IMAGE}
ENV VENV_PATH=/opt/venv
ENV PATH="${VENV_PATH}/bin:${PATH}"
ENV HF_HOME=/tmp/huggingface
ENV TRANSFORMERS_CACHE=/tmp/huggingface/transformers
ENV SENTENCE_TRANSFORMERS_HOME=/tmp/sentence-transformers
ENV TOKENIZERS_PARALLELISM=false
ENV OMP_NUM_THREADS=1
ENV MKL_NUM_THREADS=1
ENV OPENBLAS_NUM_THREADS=1
WORKDIR /program
COPY --from=builder --chown=65532:65532 ${VENV_PATH} ${VENV_PATH}
COPY --from=builder --chown=65532:65532 /inference /inference
COPY --from=builder --chown=65532:65532 /tmp/huggingface /tmp/huggingface
COPY --from=builder --chown=65532:65532 /tmp/sentence-transformers /tmp/sentence-transformers
COPY --from=builder --chown=65532:65532 /program /program
USER nonroot
CMD ["/opt/venv/bin/uvicorn", "--host", "0.0.0.0", "--port", "80", "app:app"]