forked from Unstructured-IO/unstructured-inference
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
57 lines (45 loc) · 2.1 KB
/
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
# syntax=docker/dockerfile:experimental
FROM centos:centos7.9.2009
# NOTE(crag): NB_USER ARG for mybinder.org compat:
# https://mybinder.readthedocs.io/en/latest/tutorials/dockerfile.html
ARG NB_USER=notebook-user
ARG NB_UID=1000
ARG PIP_VERSION
RUN yum -y update && \
yum -y install poppler-utils xz-devel which
# Note(yuming): Install gcc & g++ ≥ 5.4 for Detectron2 requirement
RUN yum -y update
RUN yum -y install centos-release-scl
RUN yum -y install devtoolset-7-gcc*
SHELL [ "/usr/bin/scl", "enable", "devtoolset-7"]
RUN yum -y update && \
yum -y install openssl-devel bzip2-devel libffi-devel make git sqlite-devel && \
curl -O https://www.python.org/ftp/python/3.8.14/Python-3.8.14.tgz && tar -xzf Python-3.8.14.tgz && \
cd Python-3.8.14/ && ./configure --enable-optimizations && make altinstall && \
cd .. && rm -rf Python-3.8.14*
# create user with a home directory
ENV USER ${NB_USER}
ENV HOME /home/${NB_USER}
RUN groupadd --gid ${NB_UID} ${NB_USER}
RUN useradd --uid ${NB_UID} --gid ${NB_UID} ${NB_USER}
USER ${NB_USER}
WORKDIR ${HOME}
RUN mkdir ${HOME}/.ssh && chmod go-rwx ${HOME}/.ssh \
&& ssh-keyscan -t rsa github.com >> /home/${NB_USER}/.ssh/known_hosts
ENV PYTHONPATH="${PYTHONPATH}:${HOME}"
ENV PATH="/home/${NB_USER}/.local/bin:${PATH}"
COPY logger_config.yaml logger_config.yaml
COPY requirements/dev.txt requirements-dev.txt
COPY requirements/base.txt requirements-base.txt
COPY unstructured_inference unstructured_inference
# NOTE(crag) - Cannot use an ARG in the dst= path (so it seems), hence no ${NB_USER}, ${NB_UID}
RUN python3.8 -m pip install pip==${PIP_VERSION} \
&& pip3.8 install --no-cache -r requirements-base.txt \
&& pip3.8 install --no-cache -r requirements-dev.txt \
&& pip3.8 install --no-cache "detectron2@git+https://github.com/facebookresearch/detectron2.git@e2ce8dc#egg=detectron2" \
&& python3.8 -c "import unstructured_inference.models.detectron2 as detectron2; detectron2.load_default_model()"
EXPOSE 5000
ENTRYPOINT ["uvicorn", "unstructured_inference.api:app", \
"--log-config", "logger_config.yaml", \
"--host", "0.0.0.0", \
"--port", "5000"]