-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
nlp.Dockerfile
64 lines (41 loc) · 1.85 KB
/
nlp.Dockerfile
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
54
55
56
57
58
59
60
61
62
63
64
FROM ubuntu:18.04 as base
ENV WORKDIR /home/root/app
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
ENV PYTHON_WHEELS_PATH /wheels
ENV PYTHON_BUILD_PACKAGES "software-properties-common curl"
ENV PIP_REQUIREMENTS "-r requirements.txt"
WORKDIR ${WORKDIR}
RUN apt-get update && apt-get install --no-install-recommends -y ${PYTHON_BUILD_PACKAGES} git
RUN apt-get install -y python3 python3-pip python3-venv
RUN apt-get install build-essential
RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
RUN apt-get install -y ttf-mscorefonts-installer \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
RUN bash -c "ln -s /usr/bin/python3 /usr/bin/python; ln -s /usr/bin/pip3 /usr/bin/pip"
COPY requirements.txt .
FROM base as builder
ENV BUILD_PACKAGES "build-essential"
RUN apt-get update && apt-get install --no-install-recommends -y ${BUILD_PACKAGES}
RUN pip install --upgrade pip
RUN pip install -U pip setuptools
RUN pip wheel --wheel-dir=${PYTHON_WHEELS_PATH} ${PIP_REQUIREMENTS}
FROM base
COPY --from=builder ${PYTHON_WHEELS_PATH} ${PYTHON_WHEELS_PATH}
RUN pip install --upgrade pip
RUN pip install -U pip setuptools
RUN pip install --find-links=${PYTHON_WHEELS_PATH} ${PIP_REQUIREMENTS}
COPY bothub ${WORKDIR}/bothub
COPY start_celery.py .
COPY celery_app.py .
ARG DOWNLOAD_MODELS
#Install torch with cuda 10.1
RUN if [ "${DOWNLOAD_MODELS}" = "pt_br-BERT" ]; then \
pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html; \
fi
RUN if [ ${DOWNLOAD_MODELS} ]; then \
python3.6 bothub/shared/utils/scripts/download_models.py ${DOWNLOAD_MODELS}; \
fi
ENTRYPOINT [ "celery", "worker", "--autoscale", "1,1", "-O", "fair", "--workdir", ".", "-A", "celery_app", "-c", "5", "-l", "INFO", "-E", "--pool", "threads" ]